mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-04 19:29:49 -06:00
be careful, the env:OC_EDITION, env:FRONTEND_EDITION, and conf:edition got removed as part of this commit, no deprecation because the flag is build time only!
(cherry picked from commit 40d8aacea4)
66 lines
1.3 KiB
Go
66 lines
1.3 KiB
Go
package version_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/opencloud-eu/opencloud/pkg/version"
|
|
)
|
|
|
|
func TestChannel(t *testing.T) {
|
|
tests := map[string]struct {
|
|
got string
|
|
valid bool
|
|
}{
|
|
"no channel, defaults to dev": {
|
|
got: "",
|
|
valid: false,
|
|
},
|
|
"dev channel": {
|
|
got: version.EditionDev,
|
|
valid: true,
|
|
},
|
|
"rolling channel": {
|
|
got: version.EditionRolling,
|
|
valid: true,
|
|
},
|
|
"stable channel": {
|
|
got: version.EditionStable,
|
|
valid: true,
|
|
},
|
|
"lts channel without version": {
|
|
got: version.EditionLTS,
|
|
valid: false,
|
|
},
|
|
"lts-1.0.0 channel": {
|
|
got: fmt.Sprintf("%s-1", version.EditionLTS),
|
|
valid: true,
|
|
},
|
|
"lts-one invalid version": {
|
|
got: fmt.Sprintf("%s-one", version.EditionLTS),
|
|
valid: false,
|
|
},
|
|
"known channel with version": {
|
|
got: fmt.Sprintf("%s-1", version.EditionStable),
|
|
valid: false,
|
|
},
|
|
"unknown channel": {
|
|
got: "foo",
|
|
valid: false,
|
|
},
|
|
}
|
|
|
|
for name, test := range tests {
|
|
t.Run(name, func(t *testing.T) {
|
|
version.Edition = test.got
|
|
|
|
switch err := version.InitEdition(); {
|
|
case err != nil && !test.valid && version.Edition != version.Dev: // if a given edition is unknown, the value is always dev
|
|
fallthrough
|
|
case test.valid != (err == nil):
|
|
t.Fatalf("invalid edition: %s", version.Edition)
|
|
}
|
|
})
|
|
}
|
|
}
|