binary data nope

This commit is contained in:
jregan
2020-11-19 16:46:25 -08:00
parent eda7a9f8d6
commit b88e770b1d
12 changed files with 780 additions and 584 deletions

View File

@@ -9,56 +9,6 @@ import (
"github.com/stretchr/testify/assert"
)
var input = `apiVersion: v1
kind: ConfigMap
metadata:
name: the-map
data:
altGreeting: "Good Morning!"
enableRisky: "false"
`
func TestSetK8sData(t *testing.T) {
rn := MustParse(`apiVersion: v1
kind: ConfigMap
data:
altGreeting: "Good Morning!"
`)
_, err := rn.Pipe(
SetK8sData("foo", "bar"),
SetK8sData("fruit", "apple"),
SetK8sData("veggie", "celery"))
assert.NoError(t, err)
output := rn.MustString()
expected := `apiVersion: v1
kind: ConfigMap
data:
altGreeting: "Good Morning!"
foo: bar
fruit: apple
veggie: celery
`
if !assert.Equal(t, expected, output) {
t.FailNow()
}
}
func TestSetK8sDataForbidOverwrite(t *testing.T) {
rn := MustParse(`apiVersion: v1
kind: ConfigMap
data:
altGreeting: "Good Morning!"
`)
_, err := rn.Pipe(
SetK8sData("foo", "bar"),
SetK8sData("altGreeting", "hey"),
SetK8sData("veggie", "celery"))
assert.EqualError(
t, err, "protecting existing altGreeting='\"Good Morning!\"' "+
"against attempt to add new value 'hey'")
}
func TestSetMeta(t *testing.T) {
rn := MustParse(`apiVersion: v1
kind: ConfigMap
@@ -85,7 +35,14 @@ metadata:
}
func TestSetLabel1(t *testing.T) {
rn := MustParse(input)
rn := MustParse(`apiVersion: v1
kind: ConfigMap
metadata:
name: the-map
data:
altGreeting: "Good Morning!"
enableRisky: "false"
`)
_, err := rn.Pipe(SetLabel("foo", "bar"))
if err != nil {
t.Fatalf("unexpected error %v", err)
@@ -133,7 +90,14 @@ metadata:
}
func TestAnnotation(t *testing.T) {
rn := MustParse(input)
rn := MustParse(`apiVersion: v1
kind: ConfigMap
metadata:
name: the-map
data:
altGreeting: "Good Morning!"
enableRisky: "false"
`)
_, err := rn.Pipe(SetAnnotation("foo", "bar"))
if err != nil {
t.Fatalf("unexpected error %v", err)