(t *testing.T)
| 94 | } |
| 95 | |
| 96 | func TestLookupMapPath(t *testing.T) { |
| 97 | tsts := []struct { |
| 98 | Path []string |
| 99 | Root map[string]interface{} |
| 100 | Want interface{} |
| 101 | }{ |
| 102 | {[]string{"a"}, map[string]interface{}{"a": "b"}, "b"}, |
| 103 | {[]string{"a"}, map[string]interface{}{"a": 42}, 42}, |
| 104 | {[]string{"a", "b"}, map[string]interface{}{"a": map[string]interface{}{"b": "c"}}, "c"}, |
| 105 | } |
| 106 | for _, tst := range tsts { |
| 107 | t.Run(fmt.Sprint(tst.Path, "/", tst.Want), func(t *testing.T) { |
| 108 | got, err := lookupMapPath(tst.Path, tst.Root) |
| 109 | if err != nil { |
| 110 | t.Fatalf("lookupMapPath failed: %v", err) |
| 111 | } |
| 112 | if diff := cmp.Diff(tst.Want, got); diff != "" { |
| 113 | t.Errorf("+got -want:\n%s", diff) |
| 114 | } |
| 115 | }) |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | func TestLookupMapPathInvalid(t *testing.T) { |
| 120 | tsts := []struct { |
nothing calls this directly
no test coverage detected