mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
Harden anno transformer test.
This commit is contained in:
@@ -9,8 +9,12 @@ import (
|
|||||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
func TestAnnotationsTransformer(t *testing.T) {
|
||||||
config = `
|
th := kusttest_test.MakeEnhancedHarness(t).
|
||||||
|
PrepBuiltin("AnnotationsTransformer")
|
||||||
|
defer th.Reset()
|
||||||
|
|
||||||
|
th.RunTransformerAndCheckResult(`
|
||||||
apiVersion: builtin
|
apiVersion: builtin
|
||||||
kind: AnnotationsTransformer
|
kind: AnnotationsTransformer
|
||||||
metadata:
|
metadata:
|
||||||
@@ -18,11 +22,14 @@ metadata:
|
|||||||
annotations:
|
annotations:
|
||||||
app: myApp
|
app: myApp
|
||||||
greeting/morning: a string with blanks
|
greeting/morning: a string with blanks
|
||||||
|
booleanNaked: true
|
||||||
|
booleanQuoted: "true"
|
||||||
|
numberNaked: 42
|
||||||
|
numberQuoted: "42"
|
||||||
fieldSpecs:
|
fieldSpecs:
|
||||||
- path: metadata/annotations
|
- path: metadata/annotations
|
||||||
create: true
|
create: true
|
||||||
`
|
`, `
|
||||||
input = `
|
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
@@ -30,25 +37,20 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
ports:
|
ports:
|
||||||
- port: 7002
|
- port: 7002
|
||||||
`
|
`, `
|
||||||
expectedOutput = `
|
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
app: myApp
|
app: myApp
|
||||||
|
booleanNaked: "true"
|
||||||
|
booleanQuoted: "true"
|
||||||
greeting/morning: a string with blanks
|
greeting/morning: a string with blanks
|
||||||
|
numberNaked: "42"
|
||||||
|
numberQuoted: "42"
|
||||||
name: myService
|
name: myService
|
||||||
spec:
|
spec:
|
||||||
ports:
|
ports:
|
||||||
- port: 7002
|
- port: 7002
|
||||||
`
|
`)
|
||||||
)
|
|
||||||
|
|
||||||
func TestAnnotationsTransformer(t *testing.T) {
|
|
||||||
th := kusttest_test.MakeEnhancedHarness(t).
|
|
||||||
PrepBuiltin("AnnotationsTransformer")
|
|
||||||
defer th.Reset()
|
|
||||||
|
|
||||||
th.RunTransformerAndCheckResult(config, input, expectedOutput)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user