Test JoinClause node
(t *testing.T)
| 220 | |
| 221 | // Test JoinClause node |
| 222 | func TestJoinClause(t *testing.T) { |
| 223 | tests := []struct { |
| 224 | name string |
| 225 | join *JoinClause |
| 226 | wantLiteral string |
| 227 | wantChildren int |
| 228 | }{ |
| 229 | { |
| 230 | name: "INNER JOIN", |
| 231 | join: &JoinClause{ |
| 232 | Type: "INNER", |
| 233 | Left: TableReference{Name: "users"}, |
| 234 | Right: TableReference{Name: "orders"}, |
| 235 | Condition: &Identifier{Name: "condition"}, |
| 236 | }, |
| 237 | wantLiteral: "INNER JOIN", |
| 238 | wantChildren: 3, |
| 239 | }, |
| 240 | { |
| 241 | name: "LEFT JOIN", |
| 242 | join: &JoinClause{ |
| 243 | Type: "LEFT", |
| 244 | Left: TableReference{Name: "users"}, |
| 245 | Right: TableReference{Name: "orders"}, |
| 246 | Condition: &Identifier{Name: "condition"}, |
| 247 | }, |
| 248 | wantLiteral: "LEFT JOIN", |
| 249 | wantChildren: 3, |
| 250 | }, |
| 251 | { |
| 252 | name: "JOIN without condition", |
| 253 | join: &JoinClause{ |
| 254 | Type: "CROSS", |
| 255 | Left: TableReference{Name: "users"}, |
| 256 | Right: TableReference{Name: "orders"}, |
| 257 | Condition: nil, |
| 258 | }, |
| 259 | wantLiteral: "CROSS JOIN", |
| 260 | wantChildren: 2, |
| 261 | }, |
| 262 | } |
| 263 | |
| 264 | for _, tt := range tests { |
| 265 | tt := tt // G601: Create local copy to avoid memory aliasing |
| 266 | t.Run(tt.name, func(t *testing.T) { |
| 267 | // Test TokenLiteral |
| 268 | if got := tt.join.TokenLiteral(); got != tt.wantLiteral { |
| 269 | t.Errorf("JoinClause.TokenLiteral() = %v, want %v", got, tt.wantLiteral) |
| 270 | } |
| 271 | |
| 272 | // Test Children |
| 273 | children := tt.join.Children() |
| 274 | if len(children) != tt.wantChildren { |
| 275 | t.Errorf("JoinClause.Children() count = %d, want %d", len(children), tt.wantChildren) |
| 276 | } |
| 277 | |
| 278 | // Test that it implements Expression interface |
| 279 | var _ Expression = tt.join |
nothing calls this directly
no test coverage detected