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

Commit 89a8bb9

Browse files
committed
test: make patchgenerator generic function
1 parent 66c2656 commit 89a8bb9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pkg/handlers/aws/mutation/region/inject_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ func TestRegionPatch(t *testing.T) {
2222

2323
var _ = Describe("Generate AWS Region patches", func() {
2424
// only add aws region patch
25-
regionPatchGenerator := func() mutation.GeneratePatches {
25+
patchGenerator := func() mutation.GeneratePatches {
2626
return mutation.NewMetaGeneratePatchesHandler("", NewPatch()).(mutation.GeneratePatches)
2727
}
2828
regiontests.TestGeneratePatches(
2929
GinkgoT(),
30-
regionPatchGenerator,
30+
patchGenerator,
3131
clusterconfig.MetaVariableName,
3232
v1alpha1.AWSVariableName,
3333
VariableName,

pkg/handlers/generic/mutation/httpproxy/inject_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,17 @@ func TestHTTPProxyPatch(t *testing.T) {
193193

194194
var _ = Describe("Generate HTTPProxy Patches", func() {
195195
// only add HTTPProxy patch
196-
httpProxyPatchGenerator := func() mutation.GeneratePatches {
196+
patchGenerator := func() mutation.GeneratePatches {
197+
// Always initialize the testEnv variable in the closure.
198+
// This will allow ginkgo to initialize testEnv variable during test execution time.
197199
testEnv := helpers.TestEnv
198200
return mutation.NewMetaGeneratePatchesHandler(
199201
"",
200202
NewPatch(testEnv.Client)).(mutation.GeneratePatches)
201203
}
202204
httpproxy.TestGeneratePatches(
203205
GinkgoT(),
204-
httpProxyPatchGenerator,
206+
patchGenerator,
205207
clusterconfig.MetaVariableName,
206208
VariableName,
207209
)

0 commit comments

Comments
 (0)