This repository has been 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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: unit test for individual patch generator (#21)
* test: unit test for individual patch generator * test: package level unit test for HTTPProxy * test: fix data race between multiple unit test that use envtest * test: make patchgenerator generic function * fix: linting errors after rebase from main
- Loading branch information
1 parent
bf9280c
commit 5e7fe95
Showing
12 changed files
with
196 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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, | ||
) | ||
}) |
This file contains 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 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 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 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 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 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 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