MCPcopy Create free account
hub / github.com/github/gh-aw / TestLocateJSONPathInYAML

Function TestLocateJSONPathInYAML

pkg/parser/json_path_locator_test.go:12–99  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestLocateJSONPathInYAML(t *testing.T) {
13 yamlContent := `name: John Doe
14age: 30
15tools:
16 - name: tool1
17 version: "1.0"
18 - name: tool2
19 description: "second tool"
20permissions:
21 read: true
22 write: false`
23
24 tests := []struct {
25 name string
26 jsonPath string
27 expectLine int
28 expectCol int
29 shouldFind bool
30 }{
31 {
32 name: "root level",
33 jsonPath: "",
34 expectLine: 1,
35 expectCol: 1,
36 shouldFind: true,
37 },
38 {
39 name: "simple key",
40 jsonPath: "/name",
41 expectLine: 1,
42 expectCol: 6, // After "name:"
43 shouldFind: true,
44 },
45 {
46 name: "simple key - age",
47 jsonPath: "/age",
48 expectLine: 2,
49 expectCol: 5, // After "age:"
50 shouldFind: true,
51 },
52 {
53 name: "array element",
54 jsonPath: "/tools/0",
55 expectLine: 4,
56 expectCol: 4, // Start of first array element
57 shouldFind: true,
58 },
59 {
60 name: "nested in array element",
61 jsonPath: "/tools/1",
62 expectLine: 6,
63 expectCol: 4, // Start of second array element
64 shouldFind: true,
65 },
66 {
67 name: "nested object key",
68 jsonPath: "/permissions/read",
69 expectLine: 9,

Callers

nothing calls this directly

Calls 3

LocateJSONPathInYAMLFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected