(t *testing.T)
| 192 | } |
| 193 | |
| 194 | func TestETLBatchOperations(t *testing.T) { |
| 195 | // ETL tools often use batch operations |
| 196 | tests := []struct { |
| 197 | name string |
| 198 | query string |
| 199 | returnsResults bool |
| 200 | commandType string |
| 201 | }{ |
| 202 | // Multi-value INSERT |
| 203 | { |
| 204 | name: "batch insert", |
| 205 | query: "INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.com'), (2, 'Bob', 'bob@example.com'), (3, 'Charlie', 'charlie@example.com')", |
| 206 | returnsResults: false, |
| 207 | commandType: "INSERT", |
| 208 | }, |
| 209 | |
| 210 | // TRUNCATE for full refresh |
| 211 | { |
| 212 | name: "truncate table", |
| 213 | query: "TRUNCATE TABLE etl_destination.users", |
| 214 | returnsResults: false, |
| 215 | commandType: "TRUNCATE TABLE", |
| 216 | }, |
| 217 | |
| 218 | // DELETE with subquery |
| 219 | { |
| 220 | name: "delete with subquery", |
| 221 | query: "DELETE FROM users WHERE id IN (SELECT id FROM deleted_users)", |
| 222 | returnsResults: false, |
| 223 | commandType: "DELETE", |
| 224 | }, |
| 225 | |
| 226 | // UPDATE with join pattern |
| 227 | { |
| 228 | name: "update from staging", |
| 229 | query: "UPDATE users SET name = s.name FROM staging s WHERE users.id = s.id", |
| 230 | returnsResults: false, |
| 231 | commandType: "UPDATE", |
| 232 | }, |
| 233 | } |
| 234 | |
| 235 | c := &clientConn{} |
| 236 | |
| 237 | for _, tt := range tests { |
| 238 | t.Run(tt.name, func(t *testing.T) { |
| 239 | result := queryReturnsResults(tt.query) |
| 240 | if result != tt.returnsResults { |
| 241 | t.Errorf("queryReturnsResults(%q) = %v, want %v", tt.query, result, tt.returnsResults) |
| 242 | } |
| 243 | |
| 244 | cmdType := c.getCommandType(tt.query) |
| 245 | if cmdType != tt.commandType { |
| 246 | t.Errorf("getCommandType(%q) = %q, want %q", tt.query, cmdType, tt.commandType) |
| 247 | } |
| 248 | }) |
| 249 | } |
| 250 | } |
| 251 |
nothing calls this directly
no test coverage detected