forked from UKHomeOffice/kd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
44 lines (41 loc) · 891 Bytes
/
main_test.go
File metadata and controls
44 lines (41 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"reflect"
"testing"
)
func TestSplitYamlDocs(t *testing.T) {
cases := []struct {
name string
input string
want []string
}{
{
name: "single yaml document",
input: "---\nfoo: bar\n",
want: []string{"foo: bar\n"},
},
{
name: "two yaml documents",
input: "---\nfoo: bar\n---\nanother: doc\n",
want: []string{"foo: bar\n", "another: doc\n"},
},
{
name: "two yaml documents no doc separator",
input: "foo: bar\n---\nanother: doc\n",
want: []string{"foo: bar\n", "another: doc\n"},
},
{
name: "separator in the middle of the doc",
input: "foo: '---bar'\n",
want: []string{"foo: '---bar'\n"},
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
got := splitYamlDocs(c.input)
if !reflect.DeepEqual(got, c.want) {
t.Errorf("got: %#v\nwant: %#v\n", got, c.want)
}
})
}
}