...
1
2
3
4 package yaml_test
5
6 import (
7 "testing"
8
9 "github.com/stretchr/testify/assert"
10 "sigs.k8s.io/kustomize/kyaml/yaml"
11 )
12
13 func TestSortedKeys(t *testing.T) {
14 testCases := map[string]struct {
15 input map[string]string
16 expected []string
17 }{
18 "empty": {
19 input: map[string]string{},
20 expected: []string{}},
21 "one": {
22 input: map[string]string{"a": "aaa"},
23 expected: []string{"a"}},
24 "three": {
25 input: map[string]string{"c": "ccc", "b": "bbb", "a": "aaa"},
26 expected: []string{"a", "b", "c"}},
27 }
28 for tn, tc := range testCases {
29 tc := tc
30 t.Run(tn, func(t *testing.T) {
31 if !assert.Equal(t,
32 yaml.SortedMapKeys(tc.input),
33 tc.expected) {
34 t.FailNow()
35 }
36 })
37 }
38 }
39
View as plain text