MCPcopy Create free account
hub / github.com/daodst/chat / TestLookupMapPath

Function TestLookupMapPath

internal/pushrules/util_test.go:96–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func 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
119func TestLookupMapPathInvalid(t *testing.T) {
120 tsts := []struct {

Callers

nothing calls this directly

Calls 2

lookupMapPathFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected