This repository was archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
test: move all AWS patch unit tests to their own packages #24
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
71d92a7
test: move instanceprofile tests to its own package
supershal 78b9214
test: move instancetype unit tests to its own package
supershal de13650
test: move ami unit tests to its own package
supershal 06d676a
test: move aws network tests to its own package
supershal 106a13c
test: move controlplaneloadbalancer unit tests to its own package
supershal fb1fb65
test: move aws cni unit tests to its own package
supershal 4f1a4a1
test: fix linting errors
supershal 42d1feb
test: unit tests for AWS security groups
supershal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
100 changes: 100 additions & 0 deletions
100
pkg/handlers/aws/mutation/ami/inject_control_plane_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package ami | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
"github.com/onsi/gomega" | ||
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1" | ||
|
||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/api/v1alpha1" | ||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation" | ||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest" | ||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest/request" | ||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" | ||
) | ||
|
||
var _ = Describe("Generate AMI patches for ControlPlane", func() { | ||
patchGenerator := func() mutation.GeneratePatches { | ||
return mutation.NewMetaGeneratePatchesHandler("", NewControlPlanePatch()).(mutation.GeneratePatches) | ||
} | ||
|
||
testDefs := []capitest.PatchTestDef{ | ||
{ | ||
Name: "AMI set for control plane", | ||
Vars: []runtimehooksv1.Variable{ | ||
capitest.VariableWithValue( | ||
clusterconfig.MetaVariableName, | ||
v1alpha1.AMISpec{ID: "ami-controlplane"}, | ||
clusterconfig.MetaControlPlaneConfigName, | ||
v1alpha1.AWSVariableName, | ||
VariableName, | ||
), | ||
}, | ||
RequestItem: request.NewCPAWSMachineTemplateRequestItem("1234"), | ||
ExpectedPatchMatchers: []capitest.JSONPatchMatcher{ | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/ami/id", | ||
ValueMatcher: gomega.Equal("ami-controlplane"), | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "AMI lookup format set for control plane", | ||
Vars: []runtimehooksv1.Variable{ | ||
capitest.VariableWithValue( | ||
clusterconfig.MetaVariableName, | ||
v1alpha1.AMISpec{ | ||
Lookup: &v1alpha1.AMILookup{ | ||
Format: "test-{{.kubernetesVersion}}-format", | ||
Org: "1234", | ||
BaseOS: "testOS", | ||
}, | ||
}, | ||
clusterconfig.MetaControlPlaneConfigName, | ||
v1alpha1.AWSVariableName, | ||
VariableName, | ||
), | ||
}, | ||
RequestItem: request.NewCPAWSMachineTemplateRequestItem("1234"), | ||
ExpectedPatchMatchers: []capitest.JSONPatchMatcher{ | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/imageLookupFormat", | ||
ValueMatcher: gomega.Equal("test-{{.kubernetesVersion}}-format"), | ||
}, | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/imageLookupOrg", | ||
ValueMatcher: gomega.Equal("1234"), | ||
}, | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/imageLookupBaseOS", | ||
ValueMatcher: gomega.Equal("testOS"), | ||
}, | ||
}, | ||
UnexpectedPatchMatchers: []capitest.JSONPatchMatcher{ | ||
{ | ||
Operation: "add", | ||
Path: "/spec/template/spec/ami/id", | ||
ValueMatcher: gomega.Equal(""), | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
// create test node for each case | ||
for testIdx := range testDefs { | ||
tt := testDefs[testIdx] | ||
It(tt.Name, func() { | ||
capitest.AssertGeneratePatches( | ||
GinkgoT(), | ||
patchGenerator, | ||
&tt, | ||
) | ||
}) | ||
} | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package ami | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestAMIPatch(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "AMI patches for ControlPlane and Workers suite") | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.