mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-07 16:55:15 -04:00
versionsapi: use new fetcher in upgrade-plan cmd
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
parent
9dbe6033f2
commit
22f43d32dd
2 changed files with 31 additions and 23 deletions
|
@ -20,7 +20,7 @@ import (
|
|||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||
"github.com/edgelesssys/constellation/v2/internal/logger"
|
||||
"github.com/edgelesssys/constellation/v2/internal/versionsapi-old"
|
||||
"github.com/edgelesssys/constellation/v2/internal/versionsapi"
|
||||
"github.com/spf13/afero"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -186,7 +186,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
pubK := "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEu78QgxOOcao6U91CSzEXxrKhvFTt\nJHNy+eX6EMePtDm8CnDF9HSwnTlD0itGJ/XHPQA5YX10fJAqI1y+ehlFMw==\n-----END PUBLIC KEY-----"
|
||||
|
||||
testCases := map[string]struct {
|
||||
patchLister stubPatchLister
|
||||
patchLister stubVersionListFetcher
|
||||
planner stubUpgradePlanner
|
||||
flags upgradePlanFlags
|
||||
cliVersion string
|
||||
|
@ -197,7 +197,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
wantErr bool
|
||||
}{
|
||||
"upgrades gcp": {
|
||||
patchLister: stubPatchLister{list: availablePatches},
|
||||
patchLister: stubVersionListFetcher{list: availablePatches},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "v1.0.0",
|
||||
},
|
||||
|
@ -213,7 +213,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
wantUpgrade: true,
|
||||
},
|
||||
"upgrades azure": {
|
||||
patchLister: stubPatchLister{list: availablePatches},
|
||||
patchLister: stubVersionListFetcher{list: availablePatches},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "v1.0.0",
|
||||
},
|
||||
|
@ -229,7 +229,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
wantUpgrade: true,
|
||||
},
|
||||
"current image newer than updates": {
|
||||
patchLister: stubPatchLister{list: availablePatches},
|
||||
patchLister: stubVersionListFetcher{list: availablePatches},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "v999.999.999",
|
||||
},
|
||||
|
@ -244,7 +244,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
wantUpgrade: false,
|
||||
},
|
||||
"current image newer than cli": {
|
||||
patchLister: stubPatchLister{list: availablePatches},
|
||||
patchLister: stubVersionListFetcher{list: availablePatches},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "v999.999.999",
|
||||
},
|
||||
|
@ -260,7 +260,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
wantUpgrade: false,
|
||||
},
|
||||
"upgrade to stdout": {
|
||||
patchLister: stubPatchLister{list: availablePatches},
|
||||
patchLister: stubVersionListFetcher{list: availablePatches},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "v1.0.0",
|
||||
},
|
||||
|
@ -276,7 +276,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
wantUpgrade: true,
|
||||
},
|
||||
"current image not valid": {
|
||||
patchLister: stubPatchLister{list: availablePatches},
|
||||
patchLister: stubVersionListFetcher{list: availablePatches},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "not-valid",
|
||||
},
|
||||
|
@ -292,7 +292,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
wantErr: true,
|
||||
},
|
||||
"image fetch error": {
|
||||
patchLister: stubPatchLister{err: errors.New("error")},
|
||||
patchLister: stubVersionListFetcher{err: errors.New("error")},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "v1.0.0",
|
||||
},
|
||||
|
@ -307,7 +307,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
verifier: singleUUIDVerifier(),
|
||||
},
|
||||
"measurements fetch error": {
|
||||
patchLister: stubPatchLister{list: availablePatches},
|
||||
patchLister: stubVersionListFetcher{list: availablePatches},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "v1.0.0",
|
||||
},
|
||||
|
@ -322,7 +322,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
verifier: singleUUIDVerifier(),
|
||||
},
|
||||
"failing search should not result in error": {
|
||||
patchLister: stubPatchLister{list: availablePatches},
|
||||
patchLister: stubVersionListFetcher{list: availablePatches},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "v1.0.0",
|
||||
},
|
||||
|
@ -341,7 +341,7 @@ func TestUpgradePlan(t *testing.T) {
|
|||
wantUpgrade: true,
|
||||
},
|
||||
"failing verify should not result in error": {
|
||||
patchLister: stubPatchLister{list: availablePatches},
|
||||
patchLister: stubVersionListFetcher{list: availablePatches},
|
||||
planner: stubUpgradePlanner{
|
||||
image: "v1.0.0",
|
||||
},
|
||||
|
@ -488,11 +488,11 @@ func (u stubUpgradePlanner) GetCurrentImage(context.Context) (*unstructured.Unst
|
|||
return nil, u.image, u.err
|
||||
}
|
||||
|
||||
type stubPatchLister struct {
|
||||
type stubVersionListFetcher struct {
|
||||
list versionsapi.List
|
||||
err error
|
||||
}
|
||||
|
||||
func (s stubPatchLister) PatchVersionsOf(ctx context.Context, ref, stream, minor, kind string) (*versionsapi.List, error) {
|
||||
return &s.list, s.err
|
||||
func (s stubVersionListFetcher) FetchVersionList(context.Context, versionsapi.List) (versionsapi.List, error) {
|
||||
return s.list, s.err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue