mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Improve tests for AnnotationsTransformer
This commit is contained in:
@@ -4,17 +4,14 @@
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||
)
|
||||
|
||||
func TestAnnotationsTransformer(t *testing.T) {
|
||||
th := kusttest_test.MakeEnhancedHarness(t).
|
||||
PrepBuiltin("AnnotationsTransformer")
|
||||
defer th.Reset()
|
||||
|
||||
rm := th.LoadAndRunTransformer(`
|
||||
var (
|
||||
config = `
|
||||
apiVersion: builtin
|
||||
kind: AnnotationsTransformer
|
||||
metadata:
|
||||
@@ -22,10 +19,12 @@ metadata:
|
||||
annotations:
|
||||
app: myApp
|
||||
greeting/morning: a string with blanks
|
||||
yamlSupport: %v
|
||||
fieldSpecs:
|
||||
- path: metadata/annotations
|
||||
create: true
|
||||
`, `
|
||||
`
|
||||
input = `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -33,9 +32,8 @@ metadata:
|
||||
spec:
|
||||
ports:
|
||||
- port: 7002
|
||||
`)
|
||||
|
||||
th.AssertActualEqualsExpected(rm, `
|
||||
`
|
||||
expectedOutput = `
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
@@ -46,5 +44,20 @@ metadata:
|
||||
spec:
|
||||
ports:
|
||||
- port: 7002
|
||||
`)
|
||||
`
|
||||
)
|
||||
|
||||
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()
|
||||
|
||||
cfg := fmt.Sprintf(config, b)
|
||||
rm := th.LoadAndRunTransformer(cfg, input)
|
||||
|
||||
th.AssertActualEqualsExpected(rm, expectedOutput)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user