Gather and use some of the kyaml constants.

This commit is contained in:
jregan
2020-11-16 21:26:18 -08:00
parent 2ae180ca23
commit 712276176c
4 changed files with 66 additions and 31 deletions

View File

@@ -16,7 +16,7 @@ data:
enableRisky: "false"
`
func TestSetLabel(t *testing.T) {
func TestSetLabel1(t *testing.T) {
rn := MustParse(input)
_, err := rn.Pipe(SetLabel("foo", "bar"))
if err != nil {
@@ -39,6 +39,31 @@ data:
}
}
func TestSetLabel2(t *testing.T) {
rn := MustParse(`apiVersion: v1
kind: ConfigMap
data:
altGreeting: "Good Morning!"
`)
_, err := rn.Pipe(SetLabel("foo", "bar"))
if err != nil {
t.Fatalf("unexpected error %v", err)
}
output := rn.MustString()
expected := `apiVersion: v1
kind: ConfigMap
data:
altGreeting: "Good Morning!"
metadata:
labels:
foo: 'bar'
`
if output != expected {
t.Fatalf("expected \n%s\nbut got \n%s\n", expected, output)
}
}
func TestAnnotation(t *testing.T) {
rn := MustParse(input)
_, err := rn.Pipe(SetAnnotation("foo", "bar"))