MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestString

Function TestString

backend/plugin/parser/base/json_path_test.go:9–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestString(t *testing.T) {
10 testCases := []struct {
11 nodes []SelectorNode
12 want string
13 }{
14 {
15 nodes: []SelectorNode{
16 NewItemSelector("a"),
17 NewArraySelector("b", 1),
18 NewItemSelector("c"),
19 },
20 want: "a.b[1].c",
21 },
22 }
23
24 a := require.New(t)
25
26 for _, tc := range testCases {
27 if len(tc.nodes) == 0 {
28 continue
29 }
30
31 ast := NewPathAST(tc.nodes[0])
32 next := ast.Root
33 for i := 1; i < len(tc.nodes); i++ {
34 next.SetNext(tc.nodes[i])
35 next = next.GetNext()
36 }
37
38 got, err := ast.String()
39 a.NoError(err)
40 a.Equal(tc.want, got)
41 }
42}

Callers

nothing calls this directly

Calls 7

StringMethod · 0.95
NewItemSelectorFunction · 0.85
NewArraySelectorFunction · 0.85
NewPathASTFunction · 0.85
SetNextMethod · 0.65
GetNextMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected