(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func 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 | |
| 143 | func TestOmniASTStartPosition(t *testing.T) { |
| 144 | a := require.New(t) |
nothing calls this directly
no test coverage detected