mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-05 07:45:27 -04:00
cli: fail fast when CLI and Constellation versions don't match (#1972)
* fail on version mismatch * rename to validateCLIandConstellationVersionAreEqual * fix test * image version must only be major,minor patch equal (ignore suffix) * add version support doc * fix: do not check patch version equality for image and cli * skip validate on force
This commit is contained in:
parent
90ffcd17e8
commit
1edbe962c1
6 changed files with 140 additions and 2 deletions
|
@ -270,6 +270,73 @@ func TestCheckDirClean(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestValidateCLIandConstellationVersionCompatibility(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
imageVersion string
|
||||
microServiceVersion string
|
||||
cliVersion string
|
||||
wantErr bool
|
||||
}{
|
||||
"empty": {
|
||||
imageVersion: "",
|
||||
microServiceVersion: "",
|
||||
cliVersion: "",
|
||||
wantErr: true,
|
||||
},
|
||||
"invalid when image < CLI": {
|
||||
imageVersion: "v2.7.1",
|
||||
microServiceVersion: "v2.8.0",
|
||||
cliVersion: "v2.8.0",
|
||||
wantErr: true,
|
||||
},
|
||||
"invalid when microservice < CLI": {
|
||||
imageVersion: "v2.8.0",
|
||||
microServiceVersion: "v2.7.1",
|
||||
cliVersion: "v2.8.0",
|
||||
wantErr: true,
|
||||
},
|
||||
"valid release version": {
|
||||
imageVersion: "v2.9.0",
|
||||
microServiceVersion: "v2.9.0",
|
||||
cliVersion: "2.9.0",
|
||||
},
|
||||
"valid pre-version": {
|
||||
imageVersion: "ref/main/stream/nightly/v2.9.0-pre.0.20230626150512-0a36ce61719f",
|
||||
microServiceVersion: "v2.9.0-pre.0.20230626150512-0a36ce61719f",
|
||||
cliVersion: "2.9.0-pre.0.20230626150512-0a36ce61719f",
|
||||
},
|
||||
"image version suffix need not be equal to CLI version": {
|
||||
imageVersion: "ref/main/stream/nightly/v2.9.0-pre.0.19990626150512-9z36ce61799z",
|
||||
microServiceVersion: "v2.9.0-pre.0.20230626150512-0a36ce61719f",
|
||||
cliVersion: "2.9.0-pre.0.20230626150512-0a36ce61719f",
|
||||
},
|
||||
"image version can have different patch version": {
|
||||
imageVersion: "ref/main/stream/nightly/v2.9.1-pre.0.19990626150512-9z36ce61799z",
|
||||
microServiceVersion: "v2.9.0-pre.0.20230626150512-0a36ce61719f",
|
||||
cliVersion: "2.9.0-pre.0.20230626150512-0a36ce61719f",
|
||||
},
|
||||
"microService version suffix must be equal to CLI version": {
|
||||
imageVersion: "ref/main/stream/nightly/v2.9.0-pre.0.20230626150512-0a36ce61719f",
|
||||
microServiceVersion: "v2.9.0-pre.0.19990626150512-9z36ce61799z",
|
||||
cliVersion: "2.9.0-pre.0.20230626150512-0a36ce61719f",
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for name, tc := range testCases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
err := validateCLIandConstellationVersionAreEqual(tc.cliVersion, tc.imageVersion, tc.microServiceVersion)
|
||||
|
||||
if tc.wantErr {
|
||||
assert.Error(err)
|
||||
} else {
|
||||
assert.NoError(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func intPtr(i int) *int {
|
||||
return &i
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue