MCPcopy
hub / github.com/cortexlabs/cortex / TestFlattenAllStrValues

Function TestFlattenAllStrValues

pkg/lib/configreader/interface_test.go:25–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestFlattenAllStrValues(t *testing.T) {
26 var input interface{}
27 var expected []string
28
29 input = "test"
30 expected = []string{"test"}
31 CheckFlattenAllStrValues(input, expected, t)
32
33 input = []interface{}{"test1", "test2", "test3"}
34 expected = []string{"test1", "test2", "test3"}
35 CheckFlattenAllStrValues(input, expected, t)
36
37 input = map[interface{}]interface{}{
38 "k1": "test1",
39 "k2": "test2",
40 "k3": "test3",
41 }
42 expected = []string{"test1", "test2", "test3"}
43 CheckFlattenAllStrValues(input, expected, t)
44
45 input = map[interface{}]interface{}{
46 "k1": []interface{}{"test1"},
47 "k2": "test2",
48 "k3": []interface{}{"test3", "test4"},
49 }
50 expected = []string{"test1", "test2", "test3", "test4"}
51 CheckFlattenAllStrValues(input, expected, t)
52
53 input = map[string]interface{}{
54 "k1": []interface{}{"test1"},
55 "k2": "test2",
56 "k3": []interface{}{"test3", "test4"},
57 "k4": map[string]interface{}{
58 "k2": "test6",
59 "k1": []interface{}{"test5"},
60 "k3": []interface{}{"test7", "test8"},
61 },
62 }
63 expected = []string{"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8"}
64 CheckFlattenAllStrValues(input, expected, t)
65
66 input = MustReadYAMLStr(
67 `
68 test:
69 key1: [test5]
70 key2: test6
71 key3: [test7, test8]
72 a2:
73 key1: [test1]
74 key2: test2
75 key3: [test3, test4]
76 z:
77 - key1: [test9]
78 key2: test10
79 key3: [test11, test12]
80 - key1: [test13]
81 key2: test14
82 key3: [test15, test16]

Callers

nothing calls this directly

Calls 2

CheckFlattenAllStrValuesFunction · 0.85
MustReadYAMLStrFunction · 0.85

Tested by

no test coverage detected