Better support for testing tranformers with kyaml support

This commit is contained in:
Morten Torkildsen
2020-04-02 16:02:51 -07:00
parent 04af0e6648
commit cabaccb9fd
3 changed files with 103 additions and 68 deletions

View File

@@ -4,7 +4,6 @@
package main_test
import (
"fmt"
"testing"
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
@@ -19,7 +18,6 @@ metadata:
annotations:
app: myApp
greeting/morning: a string with blanks
yamlSupport: %v
fieldSpecs:
- path: metadata/annotations
create: true
@@ -48,16 +46,9 @@ spec:
)
func TestAnnotationsTransformer(t *testing.T) {
for _, b := range []bool{true, false} {
t.Run(fmt.Sprintf("yaml-%v", b), func(t *testing.T) {
th := kusttest_test.MakeEnhancedHarness(t).
PrepBuiltin("AnnotationsTransformer")
defer th.Reset()
th := kusttest_test.MakeEnhancedHarness(t).
PrepBuiltin("AnnotationsTransformer")
defer th.Reset()
cfg := fmt.Sprintf(config, b)
rm := th.LoadAndRunTransformer(cfg, input)
th.AssertActualEqualsExpected(rm, expectedOutput)
})
}
th.RunTransformerAndCheckResult(config, input, expectedOutput)
}