...
1
16
17 package main
18
19 import (
20 "bufio"
21 "bytes"
22 "github.com/stretchr/testify/assert"
23 "testing"
24 )
25
26 func TestFetchYaml(t *testing.T) {
27 sourceYaml := ` # See the OWNERS docs at https://go.k8s.io/owners
28 approvers:
29 - dep-approvers
30 - thockin # Network
31 - liggitt
32
33 labels:
34 - sig/architecture
35 `
36
37 outputYaml := `# See the OWNERS docs at https://go.k8s.io/owners
38 approvers:
39 - dep-approvers
40 - thockin # Network
41 - liggitt
42 labels:
43 - sig/architecture
44 `
45 node, _ := fetchYaml([]byte(sourceYaml))
46 var output bytes.Buffer
47 indent := 2
48 writer := bufio.NewWriter(&output)
49 _ = streamYaml(writer, &indent, node)
50 _ = writer.Flush()
51 assert.Equal(t, outputYaml, string(output.Bytes()), "yaml was not formatted correctly")
52 }
53
View as plain text