fix: normalize version strings with build metadata in tests
This commit is contained in:
parent
f7c4e9cdde
commit
e367cd384e
1 changed files with 8 additions and 2 deletions
|
|
@ -571,11 +571,12 @@ func TestSessionCookieAllowsAuthenticatedAccess(t *testing.T) {
|
||||||
func readExpectedVersion(t *testing.T) string {
|
func readExpectedVersion(t *testing.T) string {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
versionPath := filepath.Join("VERSION")
|
// Try to read VERSION from repository root
|
||||||
|
versionPath := filepath.Join("..", "..", "VERSION")
|
||||||
data, err := os.ReadFile(versionPath)
|
data, err := os.ReadFile(versionPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Fall back to the hard-coded fallback in version manager
|
// Fall back to the hard-coded fallback in version manager
|
||||||
return "4.24.0-rc.1"
|
return "4.24.0"
|
||||||
}
|
}
|
||||||
return strings.TrimSpace(string(data))
|
return strings.TrimSpace(string(data))
|
||||||
}
|
}
|
||||||
|
|
@ -584,8 +585,13 @@ func normalizeVersion(v string) string {
|
||||||
v = strings.TrimSpace(v)
|
v = strings.TrimSpace(v)
|
||||||
v = strings.TrimPrefix(v, "v")
|
v = strings.TrimPrefix(v, "v")
|
||||||
v = strings.TrimSuffix(v, "-dirty")
|
v = strings.TrimSuffix(v, "-dirty")
|
||||||
|
// Strip pre-release metadata (after '-')
|
||||||
if idx := strings.IndexByte(v, '-'); idx >= 0 {
|
if idx := strings.IndexByte(v, '-'); idx >= 0 {
|
||||||
v = v[:idx]
|
v = v[:idx]
|
||||||
}
|
}
|
||||||
|
// Strip build metadata (after '+')
|
||||||
|
if idx := strings.IndexByte(v, '+'); idx >= 0 {
|
||||||
|
v = v[:idx]
|
||||||
|
}
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue