fix: propagate the current edition channel in the edition validation error

This commit is contained in:
Florian Schade
2025-12-18 14:03:49 +01:00
parent f341ad4fcb
commit 50ef4f2ef1
2 changed files with 8 additions and 2 deletions

View File

@@ -79,8 +79,11 @@ func initEdition() error {
_, err := semver.NewVersion(editionParts[1]) _, err := semver.NewVersion(editionParts[1])
return err == nil return err == nil
}) { }) {
Edition = Dev defer func() {
return fmt.Errorf(`unknown edition channel "%s"`, Edition) Edition = Dev
}()
return fmt.Errorf(`unknown edition channel '%s'`, Edition)
} }
return nil return nil

View File

@@ -2,6 +2,7 @@ package version_test
import ( import (
"fmt" "fmt"
"strings"
"testing" "testing"
"github.com/opencloud-eu/opencloud/pkg/version" "github.com/opencloud-eu/opencloud/pkg/version"
@@ -59,6 +60,8 @@ func TestChannel(t *testing.T) {
fallthrough fallthrough
case test.valid != (err == nil): case test.valid != (err == nil):
t.Fatalf("invalid edition: %s", version.Edition) t.Fatalf("invalid edition: %s", version.Edition)
case !test.valid && !strings.Contains(err.Error(), "'"+test.got+"'"):
t.Fatalf("no mention of invalid edition '%s' in error: %s", test.got, err.Error())
} }
}) })
} }