Skip to content

Commit d273823

Browse files
authored
refactor: Remove unused test helper function (nutanix-cloud-native#647)
**What problem does this PR solve?**: Removes unused test helper function. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 1ae0315 commit d273823

File tree

1 file changed

+0
-56
lines changed

1 file changed

+0
-56
lines changed

common/pkg/testutils/capitest/patches.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -38,62 +38,6 @@ type JSONPatchMatcher struct {
3838
ValueMatcher gomegatypes.GomegaMatcher
3939
}
4040

41-
func ValidateGeneratePatches[T mutation.GeneratePatches](
42-
t GinkgoTInterface,
43-
handlerCreator func() T,
44-
testDefs ...PatchTestDef,
45-
) {
46-
t.Helper()
47-
testFunc := func(tt *PatchTestDef) {
48-
g := gomega.NewWithT(t)
49-
h := handlerCreator()
50-
req := &runtimehooksv1.GeneratePatchesRequest{
51-
Variables: tt.Vars,
52-
Items: []runtimehooksv1.GeneratePatchesRequestItem{
53-
tt.RequestItem,
54-
{
55-
HolderReference: runtimehooksv1.HolderReference{
56-
APIVersion: clusterv1.GroupVersion.String(),
57-
Kind: "Cluster",
58-
Namespace: request.Namespace,
59-
Name: request.ClusterName,
60-
},
61-
},
62-
},
63-
}
64-
resp := &runtimehooksv1.GeneratePatchesResponse{}
65-
h.GeneratePatches(context.Background(), req, resp)
66-
expectedStatus := runtimehooksv1.ResponseStatusSuccess
67-
if tt.ExpectedFailure {
68-
expectedStatus = runtimehooksv1.ResponseStatusFailure
69-
}
70-
g.Expect(resp.Status).
71-
To(gomega.Equal(expectedStatus), fmt.Sprintf("Message: %s", resp.Message))
72-
73-
if len(tt.ExpectedPatchMatchers) == 0 {
74-
g.Expect(resp.Items).To(gomega.BeEmpty())
75-
return
76-
}
77-
g.Expect(resp.Items).To(containPatches(&tt.RequestItem, tt.ExpectedPatchMatchers...))
78-
79-
if len(tt.UnexpectedPatchMatchers) > 0 {
80-
g.Expect(resp.Items).
81-
ToNot(containPatches(&tt.RequestItem, tt.UnexpectedPatchMatchers...))
82-
}
83-
}
84-
85-
// compose Ginkgo table arguments
86-
// https://onsi.github.io/ginkgo/#table-specs for more details
87-
testArgs := make([]TableEntry, 0, len(testDefs))
88-
for testIdx := range testDefs {
89-
tt := testDefs[testIdx]
90-
testArgs = append(testArgs, Entry(tt.Name, &tt))
91-
}
92-
DescribeTable("Patches", testFunc, testArgs)
93-
}
94-
95-
// TODO(shalinpatel): AssertGeneratePatches is a replacement of ValidateGeneratePatches function.
96-
// remove ValidateGeneratePatches once all the shared test cases are moved to their own patch package.
9741
func AssertGeneratePatches[T mutation.GeneratePatches](
9842
t GinkgoTInterface,
9943
handlerCreator func() T,

0 commit comments

Comments
 (0)