From 355c8379440eb67cd215354dee86e1c63ac3155b Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Tue, 19 May 2026 16:52:08 +0000 Subject: [PATCH] test: provision migrated db for mutual-resource recursion test (WIN-1958) (#9247) Co-authored-by: Claude Opus 4.7 (1M context) --- backend/windmill-store/src/resources.rs | 26 ++++++++++--------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/backend/windmill-store/src/resources.rs b/backend/windmill-store/src/resources.rs index b8d0bdcad9..5c17308bbf 100644 --- a/backend/windmill-store/src/resources.rs +++ b/backend/windmill-store/src/resources.rs @@ -2634,12 +2634,14 @@ mod tests { // Regression test for WIN-1957: two resources whose values reference each // other via `$res:` must NOT recurse forever (stack overflow / process // crash). With the depth guard the resolution terminates with an error. - #[tokio::test] - async fn test_transform_json_value_mutual_resource_recursion_terminates() { - let db_url = std::env::var("DATABASE_URL") - .unwrap_or("postgres://postgres:changeme@localhost:5432/windmill".to_string()); - let pool = sqlx::PgPool::connect(&db_url).await.unwrap(); - + // + // This test needs the real `workspace`/`resource` schema, so it uses + // `#[sqlx::test]` which provisions a migrated ephemeral database per test + // (the bare `DATABASE_URL` database in CI has no migrations applied, which + // previously made the workspace INSERT panic with `relation "workspace" + // does not exist` — WIN-1958). + #[sqlx::test(migrations = "../migrations")] + async fn test_transform_json_value_mutual_resource_recursion_terminates(pool: DB) { let w_id = format!("dostest{}", Uuid::new_v4().simple()); sqlx::query("INSERT INTO workspace (id, name, owner) VALUES ($1, $1, 'test@windmill.dev')") @@ -2671,16 +2673,8 @@ mod tests { ) .await; - // Clean up before asserting so a failed assertion doesn't leave rows. - let _ = sqlx::query("DELETE FROM resource WHERE workspace_id = $1") - .bind(&w_id) - .execute(&pool) - .await; - let _ = sqlx::query("DELETE FROM workspace WHERE id = $1") - .bind(&w_id) - .execute(&pool) - .await; - + // The ephemeral test database is dropped automatically, so no manual + // row cleanup is required. let err = result.expect_err("mutually recursive resources should error, not crash"); assert!( err.to_string().contains("interpolation depth"),