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: unit test for individual patch generator #21
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1de8748
test: unit test for individual patch generator
supershal 83ee108
test: package level unit test for HTTPProxy
supershal 620f020
test: fix data race between multiple unit test that use envtest
supershal f3883c3
test: make patchgenerator generic function
supershal 94ce4f3
fix: linting errors after rebase from main
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
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
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
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
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
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,35 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package region | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"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" | ||
regiontests "github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/aws/mutation/region/tests" | ||
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/pkg/handlers/generic/clusterconfig" | ||
) | ||
|
||
func TestRegionPatch(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "AWS Region mutator suite") | ||
} | ||
|
||
var _ = Describe("Generate AWS Region patches", func() { | ||
// only add aws region patch | ||
patchGenerator := func() mutation.GeneratePatches { | ||
return mutation.NewMetaGeneratePatchesHandler("", NewPatch()).(mutation.GeneratePatches) | ||
} | ||
regiontests.TestGeneratePatches( | ||
GinkgoT(), | ||
patchGenerator, | ||
clusterconfig.MetaVariableName, | ||
v1alpha1.AWSVariableName, | ||
VariableName, | ||
supershal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
}) |
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
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
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
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
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
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,49 @@ | ||
// Copyright 2023 D2iQ, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package helpers | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"k8s.io/klog/v2" | ||
"k8s.io/klog/v2/textlogger" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/log" | ||
) | ||
|
||
var TestEnv *TestEnvironment | ||
|
||
// Initialize the test environment. BeforeSuite will be only executed if this package is loaded by the test. | ||
var _ = BeforeSuite(func(ctx SpecContext) { | ||
By("Initialize loggers for testing") | ||
// Uninitialized logger spits stacktrace as warning during test execution | ||
logger := textlogger.NewLogger(textlogger.NewConfig()) | ||
// use klog as the internal logger for this envtest environment. | ||
log.SetLogger(logger) | ||
// additionally force all of the controllers to use the Ginkgo logger. | ||
ctrl.SetLogger(logger) | ||
klog.InitFlags(nil) | ||
// add logger for ginkgo | ||
klog.SetOutput(GinkgoWriter) | ||
|
||
By("Starting test environment") | ||
testEnvConfig := NewTestEnvironmentConfiguration() | ||
var err error | ||
TestEnv, err = testEnvConfig.Build() | ||
if err != nil { | ||
panic(err) | ||
} | ||
By("Starting the manager") | ||
go func() { | ||
defer GinkgoRecover() | ||
Expect(TestEnv.StartManager(ctx)).To(Succeed()) | ||
}() | ||
}, NodeTimeout(60*time.Second)) | ||
|
||
var _ = AfterSuite(func(ctx context.Context) { | ||
Expect(TestEnv.Stop()).To(Succeed()) | ||
}) |
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
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.