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:
parent
5fe3b2d810
commit
a1e7862698
1 changed files with 27 additions and 3 deletions
|
@ -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 }}`),
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue