diff --git a/pkg/handlers/aws/mutation/region/inject_test.go b/pkg/handlers/aws/mutation/region/inject_test.go index 40b8d52db..4f76e95ea 100644 --- a/pkg/handlers/aws/mutation/region/inject_test.go +++ b/pkg/handlers/aws/mutation/region/inject_test.go @@ -22,12 +22,12 @@ func TestRegionPatch(t *testing.T) { var _ = Describe("Generate AWS Region patches", func() { // only add aws region patch - regionPatchGenerator := func() mutation.GeneratePatches { + patchGenerator := func() mutation.GeneratePatches { return mutation.NewMetaGeneratePatchesHandler("", NewPatch()).(mutation.GeneratePatches) } regiontests.TestGeneratePatches( GinkgoT(), - regionPatchGenerator, + patchGenerator, clusterconfig.MetaVariableName, v1alpha1.AWSVariableName, VariableName, diff --git a/pkg/handlers/generic/mutation/httpproxy/inject_test.go b/pkg/handlers/generic/mutation/httpproxy/inject_test.go index 064765538..13f183394 100644 --- a/pkg/handlers/generic/mutation/httpproxy/inject_test.go +++ b/pkg/handlers/generic/mutation/httpproxy/inject_test.go @@ -193,7 +193,9 @@ func TestHTTPProxyPatch(t *testing.T) { var _ = Describe("Generate HTTPProxy Patches", func() { // only add HTTPProxy patch - httpProxyPatchGenerator := func() mutation.GeneratePatches { + patchGenerator := func() mutation.GeneratePatches { + // Always initialize the testEnv variable in the closure. + // This will allow ginkgo to initialize testEnv variable during test execution time. testEnv := helpers.TestEnv return mutation.NewMetaGeneratePatchesHandler( "", @@ -201,7 +203,7 @@ var _ = Describe("Generate HTTPProxy Patches", func() { } httpproxy.TestGeneratePatches( GinkgoT(), - httpProxyPatchGenerator, + patchGenerator, clusterconfig.MetaVariableName, VariableName, )