(t *testing.T)
| 250 | } |
| 251 | |
| 252 | func TestETLSchemaEvolution(t *testing.T) { |
| 253 | // ETL tools handle schema changes |
| 254 | tests := []struct { |
| 255 | name string |
| 256 | query string |
| 257 | returnsResults bool |
| 258 | commandType string |
| 259 | }{ |
| 260 | // Add column |
| 261 | { |
| 262 | name: "add column", |
| 263 | query: "ALTER TABLE users ADD COLUMN phone VARCHAR", |
| 264 | returnsResults: false, |
| 265 | commandType: "ALTER TABLE", |
| 266 | }, |
| 267 | |
| 268 | // Drop column |
| 269 | { |
| 270 | name: "drop column", |
| 271 | query: "ALTER TABLE users DROP COLUMN deprecated_field", |
| 272 | returnsResults: false, |
| 273 | commandType: "ALTER TABLE", |
| 274 | }, |
| 275 | |
| 276 | // Rename column |
| 277 | { |
| 278 | name: "rename column", |
| 279 | query: "ALTER TABLE users RENAME COLUMN old_name TO new_name", |
| 280 | returnsResults: false, |
| 281 | commandType: "ALTER TABLE", |
| 282 | }, |
| 283 | |
| 284 | // Change column type |
| 285 | { |
| 286 | name: "alter column type", |
| 287 | query: "ALTER TABLE users ALTER COLUMN id TYPE BIGINT", |
| 288 | returnsResults: false, |
| 289 | commandType: "ALTER TABLE", |
| 290 | }, |
| 291 | } |
| 292 | |
| 293 | c := &clientConn{} |
| 294 | |
| 295 | for _, tt := range tests { |
| 296 | t.Run(tt.name, func(t *testing.T) { |
| 297 | result := queryReturnsResults(tt.query) |
| 298 | if result != tt.returnsResults { |
| 299 | t.Errorf("queryReturnsResults(%q) = %v, want %v", tt.query, result, tt.returnsResults) |
| 300 | } |
| 301 | |
| 302 | cmdType := c.getCommandType(tt.query) |
| 303 | if cmdType != tt.commandType { |
| 304 | t.Errorf("getCommandType(%q) = %q, want %q", tt.query, cmdType, tt.commandType) |
| 305 | } |
| 306 | }) |
| 307 | } |
| 308 | } |
| 309 |
nothing calls this directly
no test coverage detected