Signed-off-by: tison <wander4096@gmail.com>
pull/31431/head
tison 12 months ago
parent 8b7de70d1e
commit a1792f1263
No known key found for this signature in database
GPG Key ID: CD8564CB6A21E526

@ -25,7 +25,6 @@ import (
) )
func TestFuncs(t *testing.T) { func TestFuncs(t *testing.T) {
//TODO write tests for failure cases
tests := []struct { tests := []struct {
tpl, expect string tpl, expect string
vars interface{} vars interface{}
@ -136,10 +135,9 @@ keyInElement1 = "valueInElement1"`,
assert.Equal(t, tt.expect, b.String(), tt.tpl) assert.Equal(t, tt.expect, b.String(), tt.tpl)
} }
loopMap := map[string]interface{}{ nonSerializable := map[string]interface{}{
"foo": "bar", "foo": struct{ Fn func() }{},
} }
loopMap["loop"] = []interface{}{loopMap}
mustFuncsTests := []struct { mustFuncsTests := []struct {
tpl string tpl string
@ -147,18 +145,25 @@ keyInElement1 = "valueInElement1"`,
vars interface{} vars interface{}
}{{ }{{
tpl: `{{ mustToYaml . }}`, tpl: `{{ mustToYaml . }}`,
vars: loopMap, vars: nonSerializable,
}, { }, {
tpl: `{{ mustToJson . }}`, tpl: `{{ mustToJson . }}`,
vars: loopMap, vars: nonSerializable,
}, {
tpl: `{{ mustToToml . }}`,
vars: nonSerializable,
}, { }, {
tpl: `{{ toYaml . }}`, tpl: `{{ toYaml . }}`,
expect: "", // should return empty string and swallow error expect: "", // should return empty string and swallow error
vars: loopMap, vars: nonSerializable,
}, { }, {
tpl: `{{ toJson . }}`, tpl: `{{ toJson . }}`,
expect: "", // should return empty string and swallow error expect: "", // should return empty string and swallow error
vars: loopMap, vars: nonSerializable,
}, {
tpl: `{{ toToml . }}`,
expect: "", // should return empty string and swallow error
vars: nonSerializable,
}, },
} }

Loading…
Cancel
Save