Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
make helper private and pull into own test file
  • Loading branch information
bcpeinhardt committed Oct 3, 2024
commit 5919ef9f99c3584a42a914d8d404d8451b3e3b58
4 changes: 2 additions & 2 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
36 changes: 36 additions & 0 deletions codersdk/deployment_internal_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
30 changes: 0 additions & 30 deletions codersdk/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Loading