Skip to content

Commit

Permalink
fix: integration_test test_event_trigger_on_table_drop
Browse files Browse the repository at this point in the history
  • Loading branch information
akhilender-bongirwar authored Dec 9, 2024
1 parent 5ba8c03 commit 91b2306
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions extension/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,19 +887,30 @@ async fn test_event_trigger_on_table_drop() {
.await
.expect("failed to initialize vectorize job");

// Check the job table before dropping the test table
let job_count_before = common::row_count("vectorize.job", &conn).await;
assert_eq!(job_count_before, 1);

// Drop the test table
let drop_result = sqlx::query(&format!("DROP TABLE {test_table_name};"))
let drop_result = sqlx::query(&format!("DROP TABLE {test_table_name} CASCADE;"))
.execute(&conn)
.await;
assert!(drop_result.is_ok(), "Failed to drop the test table");

// Verify the job entry is removed from the vectorize.job table
// Debug: Check job table after dropping the test table
let job_count_after = common::row_count("vectorize.job", &conn).await;
assert_eq!(job_count_after, 0, "Job entry was not removed after table drop");

// Check if the job was deleted
let deleted_job = sqlx::query("SELECT * FROM vectorize.job WHERE params->>'table' = $1 AND params->>'schema' = $2")
.bind(test_table_name)
.bind("public")
.fetch_optional(&conn)
.await
.expect("Failed to fetch job");

assert!(deleted_job.is_none(), "Job was not deleted after table drop");

// Attempt to drop a non-associated table and verify no action is taken
let unrelated_table_name = format!("unrelated_test_{}", test_num);
common::init_test_table(&unrelated_table_name, &conn).await;
Expand All @@ -911,4 +922,4 @@ async fn test_event_trigger_on_table_drop() {
// Ensure vectorize.job is unaffected
let final_job_count = common::row_count("vectorize.job", &conn).await;
assert_eq!(final_job_count, 0, "vectorize.job should remain unaffected by unrelated table drops");
}
}

0 comments on commit 91b2306

Please sign in to comment.