mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
bd63aa3c6b
sed -i '1i/*\nCopyright (c) Edgeless Systems GmbH\n\nSPDX-License-Identifier: AGPL-3.0-only\n*/\n' `grep -rL --include='*.go' 'DO NOT EDIT'` gofumpt -w .
45 lines
873 B
Go
45 lines
873 B
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package gcp
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestIsGcpReleaseImage(t *testing.T) {
|
|
testCases := map[string]struct {
|
|
image string
|
|
wantVersion string
|
|
wantError bool
|
|
}{
|
|
"works for release image": {
|
|
image: "projects/constellation-images/global/images/constellation-v1-3-0",
|
|
wantVersion: "v1.3.0",
|
|
},
|
|
"breaks for debug image": {
|
|
image: "projects/constellation-images/global/images/constellation-20220805151600",
|
|
wantError: true,
|
|
},
|
|
}
|
|
|
|
for name, tc := range testCases {
|
|
t.Run(name, func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
version, err := isGcpReleaseImage(tc.image)
|
|
if tc.wantError {
|
|
assert.Error(err)
|
|
return
|
|
}
|
|
assert.NoError(err)
|
|
assert.Equal(tc.wantVersion, version)
|
|
})
|
|
}
|
|
}
|