Skip to content

Commit fa475c6

Browse files
committed
tests: yaml to/from functions
1 parent 6f304bc commit fa475c6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

internal/template/yaml_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package template
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
var testYaml = `bool: true
10+
list:
11+
- foo
12+
- bar
13+
number: 42
14+
string: test
15+
`
16+
17+
var testJson = `{"bool":true,"list":["foo","bar"],"number":42,"string":"test"}`
18+
19+
var testDict = map[string]interface{}{
20+
"bool": true,
21+
"number": 42,
22+
"string": "test",
23+
"list": []interface{}{
24+
"foo",
25+
"bar",
26+
},
27+
}
28+
29+
func TestFromYaml(t *testing.T) {
30+
assert.Equal(t, testDict, fromYaml(testYaml))
31+
assert.Equal(t, testDict, fromYaml(testJson))
32+
}
33+
34+
func TestToYaml(t *testing.T) {
35+
assert.Equal(t, testYaml, toYaml(testDict))
36+
}

0 commit comments

Comments
 (0)