(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestLocateJSONPathInYAML(t *testing.T) { |
| 13 | yamlContent := `name: John Doe |
| 14 | age: 30 |
| 15 | tools: |
| 16 | - name: tool1 |
| 17 | version: "1.0" |
| 18 | - name: tool2 |
| 19 | description: "second tool" |
| 20 | permissions: |
| 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, |
nothing calls this directly
no test coverage detected