MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestGetOmniNode

Function TestGetOmniNode

backend/plugin/parser/tidb/omni_test.go:114–141  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

112}
113
114func TestGetOmniNode(t *testing.T) {
115 a := require.New(t)
116
117 // nil base.AST returns (nil, false).
118 node, ok := GetOmniNode(nil)
119 a.Nil(node)
120 a.False(ok)
121
122 // Non-OmniAST returns (nil, false). Use the native-tidb AST wrapper.
123 nativeAST := &AST{StartPosition: &storepb.Position{Line: 1}}
124 node, ok = GetOmniNode(nativeAST)
125 a.Nil(node)
126 a.False(ok)
127
128 // OmniAST with non-nil node round-trips.
129 list, err := ParseTiDBOmni("SELECT 1")
130 a.NoError(err)
131 a.NotNil(list)
132 a.NotEmpty(list.Items)
133 wrapped := &OmniAST{
134 Node: list.Items[0],
135 Text: "SELECT 1",
136 StartPosition: &storepb.Position{Line: 1, Column: 1},
137 }
138 node, ok = GetOmniNode(wrapped)
139 a.True(ok)
140 a.Equal(list.Items[0], node)
141}
142
143func TestOmniASTStartPosition(t *testing.T) {
144 a := require.New(t)

Callers

nothing calls this directly

Calls 3

ParseTiDBOmniFunction · 0.85
GetOmniNodeFunction · 0.70
EqualMethod · 0.65

Tested by

no test coverage detected