TestFallbackUtilityCommands tests DuckDB utility commands that don't support EXPLAIN
(t *testing.T)
| 276 | |
| 277 | // TestFallbackUtilityCommands tests DuckDB utility commands that don't support EXPLAIN |
| 278 | func TestFallbackUtilityCommands(t *testing.T) { |
| 279 | if testHarness == nil || testHarness.DuckgresDB == nil { |
| 280 | t.Skip("Test harness not available") |
| 281 | } |
| 282 | |
| 283 | db := testHarness.DuckgresDB |
| 284 | |
| 285 | t.Run("attach_detach", func(t *testing.T) { |
| 286 | skipIfKnown(t) |
| 287 | |
| 288 | // ATTACH a memory database |
| 289 | _, err := db.Exec("ATTACH ':memory:' AS util_test_db") |
| 290 | if err != nil { |
| 291 | t.Fatalf("ATTACH failed: %v", err) |
| 292 | } |
| 293 | |
| 294 | // Create a table in the attached database |
| 295 | _, err = db.Exec("CREATE TABLE util_test_db.test_tbl (id INT)") |
| 296 | if err != nil { |
| 297 | t.Fatalf("CREATE TABLE in attached db failed: %v", err) |
| 298 | } |
| 299 | |
| 300 | // Query the table |
| 301 | var count int |
| 302 | err = db.QueryRow("SELECT count(*) FROM util_test_db.test_tbl").Scan(&count) |
| 303 | if err != nil { |
| 304 | t.Fatalf("Query attached db failed: %v", err) |
| 305 | } |
| 306 | |
| 307 | // DETACH the database |
| 308 | _, err = db.Exec("DETACH util_test_db") |
| 309 | if err != nil { |
| 310 | t.Fatalf("DETACH failed: %v", err) |
| 311 | } |
| 312 | }) |
| 313 | |
| 314 | // Note: CREATE/DROP SECRET tests are skipped in integration tests |
| 315 | // because DuckLake mode creates its own S3 secret which can cause conflicts. |
| 316 | // These commands work correctly - verified manually with: |
| 317 | // CREATE SECRET test (TYPE S3, KEY_ID 'x', SECRET 'y', REGION 'us-east-1') |
| 318 | // DROP SECRET test |
| 319 | |
| 320 | t.Run("use_database", func(t *testing.T) { |
| 321 | skipIfKnown(t) |
| 322 | |
| 323 | // Get current database |
| 324 | var currentDb string |
| 325 | err := db.QueryRow("SELECT current_database()").Scan(¤tDb) |
| 326 | if err != nil { |
| 327 | t.Fatalf("Get current database failed: %v", err) |
| 328 | } |
| 329 | |
| 330 | // Switch to memory database (always available) |
| 331 | _, err = db.Exec("USE memory") |
| 332 | if err != nil { |
| 333 | t.Fatalf("USE memory failed: %v", err) |
| 334 | } |
| 335 |
nothing calls this directly
no test coverage detected