From 41064c227de7831e1367587551b99df0b9ba38f2 Mon Sep 17 00:00:00 2001 From: Benjamin Peinhardt Date: Thu, 3 Oct 2024 14:42:52 +0000 Subject: [PATCH 1/5] fix bug with trailing version info not being properly stripped --- codersdk/deployment.go | 6 +++++- codersdk/deployment_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 05f31272a1807..60877ee2f7687 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -804,8 +804,12 @@ func DefaultSupportLinks(docsURL string) []LinkConfig { } } +func RemoveTrailingVersionInfo(v string) string { + return strings.Split(strings.Split(v, "-")[0], "+")[0] +} + func DefaultDocsURL() string { - version := strings.Split(buildinfo.Version(), "-")[0] + version := RemoveTrailingVersionInfo(buildinfo.Version()) if version == "v0.0.0" { return "https://coder.com/docs" } diff --git a/codersdk/deployment_test.go b/codersdk/deployment_test.go index d7eca6323000c..d11a1fa4d466f 100644 --- a/codersdk/deployment_test.go +++ b/codersdk/deployment_test.go @@ -565,3 +565,38 @@ func TestPremiumSuperSet(t *testing.T) { require.NotContains(t, enterprise.Features(), "", "enterprise should not contain empty string") require.NotContains(t, premium.Features(), "", "premium should not contain empty string") } + +func TestRemoveTrailingVersionInfo(t *testing.T) { + t.Parallel() + + testCases := []struct { + Name string + Version string + ExpectedAfterStrippingInfo string + }{ + { + Version: "v2.16.0+683a720", + ExpectedAfterStrippingInfo: "v2.16.0", + }, + { + Version: "v2.16.0-devel+683a720)", + ExpectedAfterStrippingInfo: "v2.16.0", + }, + } + + for _, tc := range testCases { + // Is this still necessary? + tc := tc + + t.Run(tc.Name, func(t *testing.T) { + t.Parallel() + + stripped := codersdk.RemoveTrailingVersionInfo(tc.Version) + if !assert.Equal(t, tc.ExpectedAfterStrippingInfo, stripped) { + // Log relevant information if the assertion fails + t.Logf("Test failed for case: %s\nExpected: %s\nGot: %s", tc.Name, tc.ExpectedAfterStrippingInfo, stripped) + } + + }) + } +} From d796aa8fe5f4e2e89f5e58514a5196aada0c2748 Mon Sep 17 00:00:00 2001 From: Benjamin Peinhardt Date: Thu, 3 Oct 2024 15:09:06 +0000 Subject: [PATCH 2/5] revise test structure --- codersdk/deployment_test.go | 13 +---- site/src/theme/icons.json | 94 ------------------------------------- 2 files changed, 2 insertions(+), 105 deletions(-) delete mode 100644 site/src/theme/icons.json diff --git a/codersdk/deployment_test.go b/codersdk/deployment_test.go index d11a1fa4d466f..fbc607c7c0dcb 100644 --- a/codersdk/deployment_test.go +++ b/codersdk/deployment_test.go @@ -570,7 +570,6 @@ func TestRemoveTrailingVersionInfo(t *testing.T) { t.Parallel() testCases := []struct { - Name string Version string ExpectedAfterStrippingInfo string }{ @@ -588,15 +587,7 @@ func TestRemoveTrailingVersionInfo(t *testing.T) { // Is this still necessary? tc := tc - t.Run(tc.Name, func(t *testing.T) { - t.Parallel() - - stripped := codersdk.RemoveTrailingVersionInfo(tc.Version) - if !assert.Equal(t, tc.ExpectedAfterStrippingInfo, stripped) { - // Log relevant information if the assertion fails - t.Logf("Test failed for case: %s\nExpected: %s\nGot: %s", tc.Name, tc.ExpectedAfterStrippingInfo, stripped) - } - - }) + stripped := codersdk.RemoveTrailingVersionInfo(tc.Version) + require.Equal(t, tc.ExpectedAfterStrippingInfo, stripped) } } diff --git a/site/src/theme/icons.json b/site/src/theme/icons.json deleted file mode 100644 index 7fea2d79bd29e..0000000000000 --- a/site/src/theme/icons.json +++ /dev/null @@ -1,94 +0,0 @@ -[ - "almalinux.svg", - "android-studio.svg", - "apache-guacamole.svg", - "apple-black.svg", - "apple-grey.svg", - "aws-dark.svg", - "aws-light.svg", - "aws-monochrome.svg", - "aws.png", - "aws.svg", - "azure-devops.svg", - "azure.png", - "azure.svg", - "bitbucket.svg", - "centos.svg", - "clion.svg", - "code.svg", - "coder.svg", - "conda.svg", - "confluence.svg", - "container.svg", - "cpp.svg", - "cursor.svg", - "database.svg", - "datagrip.svg", - "dataspell.svg", - "debian.svg", - "desktop.svg", - "discord.svg", - "do.png", - "docker-white.svg", - "docker.png", - "docker.svg", - "dotfiles.svg", - "dotnet.svg", - "fedora.svg", - "fleet.svg", - "fly.io.svg", - "folder.svg", - "gateway.svg", - "gcp.png", - "git.svg", - "gitea.svg", - "github.svg", - "gitlab.svg", - "go.svg", - "goland.svg", - "google.svg", - "image.svg", - "intellij.svg", - "java.svg", - "javascript.svg", - "jax.svg", - "jfrog.svg", - "jupyter.svg", - "k8s.png", - "kasmvnc.svg", - "kotlin.svg", - "lxc.svg", - "matlab.svg", - "memory.svg", - "microsoft-teams.svg", - "microsoft.svg", - "nix.svg", - "node.svg", - "nodejs.svg", - "nomad.svg", - "novnc.svg", - "okta.svg", - "personalize.svg", - "php.svg", - "phpstorm.svg", - "projector.svg", - "pycharm.svg", - "python.svg", - "pytorch.svg", - "rider.svg", - "rockylinux.svg", - "rstudio.svg", - "ruby.png", - "rubymine.svg", - "rust.svg", - "slack.svg", - "swift.svg", - "tensorflow.svg", - "terminal.svg", - "theia.svg", - "typescript.svg", - "ubuntu.svg", - "vault.svg", - "webstorm.svg", - "widgets.svg" -] From c5080e5f6a319c7a0c6876c1f9646a4d14604dd9 Mon Sep 17 00:00:00 2001 From: Benjamin Peinhardt Date: Thu, 3 Oct 2024 15:34:41 +0000 Subject: [PATCH 3/5] add back the icons I somehow deleted --- site/src/theme/icons.json | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 site/src/theme/icons.json diff --git a/site/src/theme/icons.json b/site/src/theme/icons.json new file mode 100644 index 0000000000000..7fea2d79bd29e --- /dev/null +++ b/site/src/theme/icons.json @@ -0,0 +1,94 @@ +[ + "almalinux.svg", + "android-studio.svg", + "apache-guacamole.svg", + "apple-black.svg", + "apple-grey.svg", + "aws-dark.svg", + "aws-light.svg", + "aws-monochrome.svg", + "aws.png", + "aws.svg", + "azure-devops.svg", + "azure.png", + "azure.svg", + "bitbucket.svg", + "centos.svg", + "clion.svg", + "code.svg", + "coder.svg", + "conda.svg", + "confluence.svg", + "container.svg", + "cpp.svg", + "cursor.svg", + "database.svg", + "datagrip.svg", + "dataspell.svg", + "debian.svg", + "desktop.svg", + "discord.svg", + "do.png", + "docker-white.svg", + "docker.png", + "docker.svg", + "dotfiles.svg", + "dotnet.svg", + "fedora.svg", + "fleet.svg", + "fly.io.svg", + "folder.svg", + "gateway.svg", + "gcp.png", + "git.svg", + "gitea.svg", + "github.svg", + "gitlab.svg", + "go.svg", + "goland.svg", + "google.svg", + "image.svg", + "intellij.svg", + "java.svg", + "javascript.svg", + "jax.svg", + "jfrog.svg", + "jupyter.svg", + "k8s.png", + "kasmvnc.svg", + "kotlin.svg", + "lxc.svg", + "matlab.svg", + "memory.svg", + "microsoft-teams.svg", + "microsoft.svg", + "nix.svg", + "node.svg", + "nodejs.svg", + "nomad.svg", + "novnc.svg", + "okta.svg", + "personalize.svg", + "php.svg", + "phpstorm.svg", + "projector.svg", + "pycharm.svg", + "python.svg", + "pytorch.svg", + "rider.svg", + "rockylinux.svg", + "rstudio.svg", + "ruby.png", + "rubymine.svg", + "rust.svg", + "slack.svg", + "swift.svg", + "tensorflow.svg", + "terminal.svg", + "theia.svg", + "typescript.svg", + "ubuntu.svg", + "vault.svg", + "webstorm.svg", + "widgets.svg" +] From 5ebb410a5b6a6a5c0f7cc8e1d8e8388751228d80 Mon Sep 17 00:00:00 2001 From: Benjamin Peinhardt Date: Thu, 3 Oct 2024 16:37:16 +0000 Subject: [PATCH 4/5] new test case --- codersdk/deployment_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/codersdk/deployment_test.go b/codersdk/deployment_test.go index fbc607c7c0dcb..3271d750a4325 100644 --- a/codersdk/deployment_test.go +++ b/codersdk/deployment_test.go @@ -578,7 +578,11 @@ func TestRemoveTrailingVersionInfo(t *testing.T) { ExpectedAfterStrippingInfo: "v2.16.0", }, { - Version: "v2.16.0-devel+683a720)", + Version: "v2.16.0-devel+683a720", + ExpectedAfterStrippingInfo: "v2.16.0", + }, + { + Version: "v2.16.0+683a720-devel", ExpectedAfterStrippingInfo: "v2.16.0", }, } From 5919ef9f99c3584a42a914d8d404d8451b3e3b58 Mon Sep 17 00:00:00 2001 From: Benjamin Peinhardt Date: Thu, 3 Oct 2024 17:18:23 +0000 Subject: [PATCH 5/5] make helper private and pull into own test file --- codersdk/deployment.go | 4 ++-- codersdk/deployment_internal_test.go | 36 ++++++++++++++++++++++++++++ codersdk/deployment_test.go | 30 ----------------------- 3 files changed, 38 insertions(+), 32 deletions(-) create mode 100644 codersdk/deployment_internal_test.go diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 60877ee2f7687..d6840df504b85 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -804,12 +804,12 @@ func DefaultSupportLinks(docsURL string) []LinkConfig { } } -func RemoveTrailingVersionInfo(v string) string { +func removeTrailingVersionInfo(v string) string { return strings.Split(strings.Split(v, "-")[0], "+")[0] } func DefaultDocsURL() string { - version := RemoveTrailingVersionInfo(buildinfo.Version()) + version := removeTrailingVersionInfo(buildinfo.Version()) if version == "v0.0.0" { return "https://coder.com/docs" } diff --git a/codersdk/deployment_internal_test.go b/codersdk/deployment_internal_test.go new file mode 100644 index 0000000000000..09ee7f2a2cc71 --- /dev/null +++ b/codersdk/deployment_internal_test.go @@ -0,0 +1,36 @@ +package codersdk + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestRemoveTrailingVersionInfo(t *testing.T) { + t.Parallel() + + testCases := []struct { + Version string + ExpectedAfterStrippingInfo string + }{ + { + Version: "v2.16.0+683a720", + ExpectedAfterStrippingInfo: "v2.16.0", + }, + { + Version: "v2.16.0-devel+683a720", + ExpectedAfterStrippingInfo: "v2.16.0", + }, + { + Version: "v2.16.0+683a720-devel", + ExpectedAfterStrippingInfo: "v2.16.0", + }, + } + + for _, tc := range testCases { + tc := tc + + stripped := removeTrailingVersionInfo(tc.Version) + require.Equal(t, tc.ExpectedAfterStrippingInfo, stripped) + } +} diff --git a/codersdk/deployment_test.go b/codersdk/deployment_test.go index 3271d750a4325..d7eca6323000c 100644 --- a/codersdk/deployment_test.go +++ b/codersdk/deployment_test.go @@ -565,33 +565,3 @@ func TestPremiumSuperSet(t *testing.T) { require.NotContains(t, enterprise.Features(), "", "enterprise should not contain empty string") require.NotContains(t, premium.Features(), "", "premium should not contain empty string") } - -func TestRemoveTrailingVersionInfo(t *testing.T) { - t.Parallel() - - testCases := []struct { - Version string - ExpectedAfterStrippingInfo string - }{ - { - Version: "v2.16.0+683a720", - ExpectedAfterStrippingInfo: "v2.16.0", - }, - { - Version: "v2.16.0-devel+683a720", - ExpectedAfterStrippingInfo: "v2.16.0", - }, - { - Version: "v2.16.0+683a720-devel", - ExpectedAfterStrippingInfo: "v2.16.0", - }, - } - - for _, tc := range testCases { - // Is this still necessary? - tc := tc - - stripped := codersdk.RemoveTrailingVersionInfo(tc.Version) - require.Equal(t, tc.ExpectedAfterStrippingInfo, stripped) - } -}