Test CommonTableExpr node
(t *testing.T)
| 95 | |
| 96 | // Test CommonTableExpr node |
| 97 | func TestCommonTableExpr(t *testing.T) { |
| 98 | tests := []struct { |
| 99 | name string |
| 100 | cte *CommonTableExpr |
| 101 | wantLiteral string |
| 102 | wantChildren int |
| 103 | }{ |
| 104 | { |
| 105 | name: "simple CTE", |
| 106 | cte: &CommonTableExpr{ |
| 107 | Name: "my_cte", |
| 108 | Statement: &SelectStatement{}, |
| 109 | }, |
| 110 | wantLiteral: "my_cte", |
| 111 | wantChildren: 1, |
| 112 | }, |
| 113 | { |
| 114 | name: "CTE with columns", |
| 115 | cte: &CommonTableExpr{ |
| 116 | Name: "cte_with_cols", |
| 117 | Columns: []string{"col1", "col2", "col3"}, |
| 118 | Statement: &SelectStatement{}, |
| 119 | }, |
| 120 | wantLiteral: "cte_with_cols", |
| 121 | wantChildren: 1, |
| 122 | }, |
| 123 | } |
| 124 | |
| 125 | for _, tt := range tests { |
| 126 | tt := tt // G601: Create local copy to avoid memory aliasing |
| 127 | t.Run(tt.name, func(t *testing.T) { |
| 128 | // Test TokenLiteral |
| 129 | if got := tt.cte.TokenLiteral(); got != tt.wantLiteral { |
| 130 | t.Errorf("CommonTableExpr.TokenLiteral() = %v, want %v", got, tt.wantLiteral) |
| 131 | } |
| 132 | |
| 133 | // Test Children |
| 134 | children := tt.cte.Children() |
| 135 | if len(children) != tt.wantChildren { |
| 136 | t.Errorf("CommonTableExpr.Children() count = %d, want %d", len(children), tt.wantChildren) |
| 137 | } |
| 138 | |
| 139 | // Test that it implements Statement interface |
| 140 | var _ Statement = tt.cte |
| 141 | tt.cte.statementNode() |
| 142 | }) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | // Test SetOperation node |
| 147 | func TestSetOperation(t *testing.T) { |
nothing calls this directly
no test coverage detected