Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit f528a9d

Browse files
authored
test: move generic patch unit tests to own packages (#31)
* test: move audit policy tests to their own package * test: move etcd unit tests to their own package * test: move extra api server cert sans to its own package * test: move image registry unit tests to its own package * test: move kubernetes image repository unit tests * test: move mirror unit tests * test: move users unit tests * test: remove gereric unit tests from nutanix meta patch handler * test: cleaned up meta level unit test suites
1 parent c662b02 commit f528a9d

File tree

16 files changed

+618
-927
lines changed

16 files changed

+618
-927
lines changed

pkg/handlers/aws/mutation/metapatch_handler_test.go

Lines changed: 0 additions & 87 deletions
This file was deleted.

pkg/handlers/aws/mutation/suite_test.go

Lines changed: 0 additions & 48 deletions
This file was deleted.

pkg/handlers/docker/mutation/metapatch_handler_test.go

Lines changed: 0 additions & 87 deletions
This file was deleted.

pkg/handlers/docker/mutation/suite_test.go

Lines changed: 0 additions & 48 deletions
This file was deleted.

pkg/handlers/generic/mutation/auditpolicy/tests/generate_patches.go renamed to pkg/handlers/generic/mutation/auditpolicy/inject_test.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
// Copyright 2023 D2iQ, Inc. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package tests
4+
package auditpolicy
55

66
import (
77
"testing"
88

9+
. "github.com/onsi/ginkgo/v2"
910
"github.com/onsi/gomega"
1011

1112
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation"
1213
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest"
1314
"github.com/d2iq-labs/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest/request"
1415
)
1516

16-
func TestGeneratePatches(
17-
t *testing.T, generatorFunc func() mutation.GeneratePatches,
18-
) {
19-
t.Helper()
17+
func TestAuditPolicyPatch(t *testing.T) {
18+
gomega.RegisterFailHandler(Fail)
19+
RunSpecs(t, "Audit Policy mutator suite")
20+
}
21+
22+
var _ = Describe("Generate Audit Policy patches", func() {
23+
patchGenerator := func() mutation.GeneratePatches {
24+
return mutation.NewMetaGeneratePatchesHandler("", NewPatch()).(mutation.GeneratePatches)
25+
}
2026

21-
capitest.ValidateGeneratePatches(
22-
t,
23-
generatorFunc,
24-
capitest.PatchTestDef{
27+
testDefs := []capitest.PatchTestDef{
28+
{
2529
Name: "unset variable",
2630
},
27-
capitest.PatchTestDef{
31+
{
2832
Name: "auditpolicy set for KubeadmControlPlaneTemplate",
2933
RequestItem: request.NewKubeadmControlPlaneTemplateRequestItem(""),
3034
ExpectedPatchMatchers: []capitest.JSONPatchMatcher{{
@@ -71,5 +75,13 @@ func TestGeneratePatches(
7175
),
7276
}},
7377
},
74-
)
75-
}
78+
}
79+
80+
// create test node for each case
81+
for testIdx := range testDefs {
82+
tt := testDefs[testIdx]
83+
It(tt.Name, func() {
84+
capitest.AssertGeneratePatches(GinkgoT(), patchGenerator, &tt)
85+
})
86+
}
87+
})

0 commit comments

Comments
 (0)