MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestTableReference

Function TestTableReference

pkg/sql/ast/nodes_test.go:286–328  ·  view source on GitHub ↗

Test TableReference node

(t *testing.T)

Source from the content-addressed store, hash-verified

284
285// Test TableReference node
286func TestTableReference(t *testing.T) {
287 tests := []struct {
288 name string
289 tableRef *TableReference
290 wantLiteral string
291 }{
292 {
293 name: "simple table",
294 tableRef: &TableReference{Name: "users"},
295 wantLiteral: "users",
296 },
297 {
298 name: "table with alias",
299 tableRef: &TableReference{Name: "users", Alias: "u"},
300 wantLiteral: "users",
301 },
302 {
303 name: "qualified table name",
304 tableRef: &TableReference{Name: "schema.table"},
305 wantLiteral: "schema.table",
306 },
307 }
308
309 for _, tt := range tests {
310 tt := tt // G601: Create local copy to avoid memory aliasing
311 t.Run(tt.name, func(t *testing.T) {
312 // Test TokenLiteral
313 if got := tt.tableRef.TokenLiteral(); got != tt.wantLiteral {
314 t.Errorf("TableReference.TokenLiteral() = %v, want %v", got, tt.wantLiteral)
315 }
316
317 // Test Children
318 children := tt.tableRef.Children()
319 if children != nil {
320 t.Errorf("TableReference.Children() = %v, want nil", children)
321 }
322
323 // Test that it implements Statement interface
324 var _ Statement = tt.tableRef
325 tt.tableRef.statementNode()
326 })
327 }
328}
329
330// Test WindowSpec node
331func TestWindowSpec(t *testing.T) {

Callers

nothing calls this directly

Calls 5

RunMethod · 0.80
TokenLiteralMethod · 0.65
ErrorfMethod · 0.65
ChildrenMethod · 0.65
statementNodeMethod · 0.65

Tested by

no test coverage detected