mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-01 21:10:13 +00:00
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 {
|
||||
t.Helper()
|
||||
|
||||
versionPath := filepath.Join("VERSION")
|
||||
// Try to read VERSION from repository root
|
||||
versionPath := filepath.Join("..", "..", "VERSION")
|
||||
data, err := os.ReadFile(versionPath)
|
||||
if err != nil {
|
||||
// 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))
|
||||
}
|
||||
|
|
@ -584,8 +585,13 @@ func normalizeVersion(v string) string {
|
|||
v = strings.TrimSpace(v)
|
||||
v = strings.TrimPrefix(v, "v")
|
||||
v = strings.TrimSuffix(v, "-dirty")
|
||||
// Strip pre-release metadata (after '-')
|
||||
if idx := strings.IndexByte(v, '-'); idx >= 0 {
|
||||
v = v[:idx]
|
||||
}
|
||||
// Strip build metadata (after '+')
|
||||
if idx := strings.IndexByte(v, '+'); idx >= 0 {
|
||||
v = v[:idx]
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue