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

test: move generic patch unit tests to own packages #31

Merged
87 changes: 0 additions & 87 deletions pkg/handlers/aws/mutation/metapatch_handler_test.go

This file was deleted.

48 changes: 0 additions & 48 deletions pkg/handlers/aws/mutation/suite_test.go

This file was deleted.

87 changes: 0 additions & 87 deletions pkg/handlers/docker/mutation/metapatch_handler_test.go

This file was deleted.

48 changes: 0 additions & 48 deletions pkg/handlers/docker/mutation/suite_test.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
// Copyright 2023 D2iQ, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package tests
package auditpolicy

import (
"testing"

. "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

"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"
)

func TestGeneratePatches(
t *testing.T, generatorFunc func() mutation.GeneratePatches,
) {
t.Helper()
func TestAuditPolicyPatch(t *testing.T) {
gomega.RegisterFailHandler(Fail)
RunSpecs(t, "Audit Policy mutator suite")
}

var _ = Describe("Generate Audit Policy patches", func() {
patchGenerator := func() mutation.GeneratePatches {
return mutation.NewMetaGeneratePatchesHandler("", NewPatch()).(mutation.GeneratePatches)
}

capitest.ValidateGeneratePatches(
t,
generatorFunc,
capitest.PatchTestDef{
testDefs := []capitest.PatchTestDef{
{
Name: "unset variable",
},
capitest.PatchTestDef{
{
Name: "auditpolicy set for KubeadmControlPlaneTemplate",
RequestItem: request.NewKubeadmControlPlaneTemplateRequestItem(""),
ExpectedPatchMatchers: []capitest.JSONPatchMatcher{{
Expand Down Expand Up @@ -71,5 +75,13 @@ func TestGeneratePatches(
),
}},
},
)
}
}

// create test node for each case
for testIdx := range testDefs {
tt := testDefs[testIdx]
It(tt.Name, func() {
capitest.AssertGeneratePatches(GinkgoT(), patchGenerator, &tt)
})
}
})
Loading