From e367cd384ef0f0a77c30f3d19ba439e77ec77cf6 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 16 Oct 2025 09:07:40 +0000 Subject: [PATCH] fix: normalize version strings with build metadata in tests --- internal/api/router_integration_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/api/router_integration_test.go b/internal/api/router_integration_test.go index d4af24b..6073e60 100644 --- a/internal/api/router_integration_test.go +++ b/internal/api/router_integration_test.go @@ -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 }