MCPcopy
hub / github.com/grafana/tempo / TestListToMapMarshalOperationsYAML

Function TestListToMapMarshalOperationsYAML

pkg/util/listtomap/list_to_map_test.go:11–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestListToMapMarshalOperationsYAML(t *testing.T) {
12 testCases := []struct {
13 name string
14 inputYAML string
15 expectedListToMapYAML ListToMap
16 marshalledYAML string
17 }{
18 {
19 name: "empty map",
20 inputYAML: "",
21 expectedListToMapYAML: ListToMap{},
22 marshalledYAML: "null\n",
23 },
24 {
25 name: "map with entries",
26 inputYAML: "- foo",
27 expectedListToMapYAML: ListToMap{
28 "foo": {},
29 },
30 marshalledYAML: "- foo\n",
31 },
32 {
33 name: "explicit string entries",
34 inputYAML: "- \"foo\"",
35 expectedListToMapYAML: ListToMap{
36 "foo": {},
37 },
38 marshalledYAML: "- foo\n",
39 },
40 }
41
42 for _, tc := range testCases {
43 t.Run(tc.name, func(t *testing.T) {
44 // YAML to struct
45 var l ListToMap
46 assert.NoError(t, yaml.Unmarshal([]byte(tc.inputYAML), &l))
47 assert.NotNil(t, l.GetMap())
48 assert.Equal(t, tc.expectedListToMapYAML, l)
49
50 // struct to YAML
51 bytes, err := yaml.Marshal(tc.expectedListToMapYAML)
52 assert.NoError(t, err)
53 assert.Equal(t, tc.marshalledYAML, string(bytes))
54 })
55 }
56}
57
58func TestListToMapMarshalOperationsJSON(t *testing.T) {
59 testCases := []struct {

Callers

nothing calls this directly

Calls 5

GetMapMethod · 0.95
UnmarshalMethod · 0.65
MarshalMethod · 0.65
RunMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected