1
0
Fork 0
mirror of https://github.com/external-secrets/external-secrets.git synced 2024-12-15 17:51:01 +00:00

add tests

This commit is contained in:
marcincuber 2022-06-11 11:15:06 +01:00
parent 5fe3b2d810
commit a1e7862698

View file

@ -159,7 +159,7 @@ func TestExecute(t *testing.T) {
},
},
{
name: "fromJSON func",
name: "fromJson func",
tpl: map[string][]byte{
"foo": []byte("{{ $var := .secret | fromJson }}{{ $var.foo }}"),
},
@ -171,7 +171,7 @@ func TestExecute(t *testing.T) {
},
},
{
name: "from & toJSON func",
name: "from & toJson func",
tpl: map[string][]byte{
"foo": []byte("{{ $var := .secret | fromJson }}{{ $var.foo | toJson }}"),
},
@ -182,6 +182,30 @@ func TestExecute(t *testing.T) {
"foo": []byte(`{"baz":"bang"}`),
},
},
{
name: "fromJson & toYaml func",
tpl: map[string][]byte{
"foo": []byte("{{ $var := .secret | fromJson | toYaml }}{{ $var }}"),
},
data: map[string][]byte{
"secret": []byte(`{"foo": "bar"}`),
},
expetedData: map[string][]byte{
"foo": []byte(`foo: bar`),
},
},
{
name: "fromYaml & toJson func",
tpl: map[string][]byte{
"foo": []byte("{{ $var := .secret | fromYaml | toJson }}{{ $var }}"),
},
data: map[string][]byte{
"secret": []byte(`foo: bar`),
},
expetedData: map[string][]byte{
"foo": []byte(`{"foo": "bar"}`),
},
},
{
name: "use sprig functions",
tpl: map[string][]byte{
@ -302,7 +326,7 @@ func TestExecute(t *testing.T) {
expErr: "unable to decode pkcs12",
},
{
name: "fromJSON error",
name: "fromJson error",
tpl: map[string][]byte{
"key": []byte(`{{ "{ # no json # }" | fromJson }}`),
},