Files
coder/codersdk/deployment_internal_test.go
Cian Johnston 2a51687ff3 fix: stop amputating RC suffixes from docs URLs (#23903)
Fixes #23897 (docs link only — naming rename is in #23905)

- Fix version stripping logic in both Go (`codersdk/deployment.go`) and
TypeScript (`site/src/utils/docs.ts`) to preserve `-rc.X` suffixes
instead of amputating them along with `-devel`
- Add `v0.0.0` fallback in the TS frontend to match Go backend behavior
for dev builds
- Add tests covering RC, devel, and plain release version strings

> 🤖 Written by a Coder Agent. Will be reviewed by a human.
2026-04-01 13:05:14 +00:00

61 lines
1.4 KiB
Go

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",
},
// RC versions: preserve the -rc.X suffix, strip build metadata.
{
Version: "v2.32.0-rc.1+abc123",
ExpectedAfterStrippingInfo: "v2.32.0-rc.1",
},
{
Version: "v2.32.0-rc.0",
ExpectedAfterStrippingInfo: "v2.32.0-rc.0",
},
{
Version: "v2.32.0-rc.1+683a720-devel",
ExpectedAfterStrippingInfo: "v2.32.0-rc.1",
},
// Bare devel suffix, no build metadata.
{
Version: "v2.32.0-devel",
ExpectedAfterStrippingInfo: "v2.32.0",
},
// Plain release, identity case.
{
Version: "v2.16.0",
ExpectedAfterStrippingInfo: "v2.16.0",
},
}
for _, tc := range testCases {
t.Run(tc.Version, func(t *testing.T) {
t.Parallel()
stripped := removeTrailingVersionInfo(tc.Version)
require.Equal(t, tc.ExpectedAfterStrippingInfo, stripped)
})
}
}