From ea7ed23bb0b710cc76edab80d18bfd0873c9f1e3 Mon Sep 17 00:00:00 2001 From: Drew Robinson Date: Wed, 2 Dec 2026 11:39:45 +1100 Subject: [PATCH] test: supervise the shared Integration.TestRepo in setup_all Four modules started EctoLibSql.Integration.TestRepo with start_link in setup_all and never stopped it. The repo died only when its linked setup_all process exited, asynchronously, so the next module could find the name still registered and fail with :already_started, invalidating every test in it. start_supervised! stops the repo before the next module runs. Closes kata rsn2. Claude-Session: https://claude.ai/code/session_01LR8MxKNHZfhfopXM58LKwG --- test/ecto_sqlite3_crud_compat_test.exs | 3 ++- test/ecto_sqlite3_returning_debug_test.exs | 3 ++- test/in_expression_comprehensive_test.exs | 3 ++- test/returning_clause_test.exs | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/ecto_sqlite3_crud_compat_test.exs b/test/ecto_sqlite3_crud_compat_test.exs index 593cc7eb..1561f12e 100644 --- a/test/ecto_sqlite3_crud_compat_test.exs +++ b/test/ecto_sqlite3_crud_compat_test.exs @@ -25,7 +25,8 @@ defmodule EctoLibSql.EctoSqlite3CrudCompatTest do database: @test_db ) - {:ok, _} = EctoLibSql.Integration.TestRepo.start_link() + # Supervised so ExUnit stops the shared repo before the next module starts it. + start_supervised!(EctoLibSql.Integration.TestRepo) # Create tables manually - migration approach has ID generation issues Ecto.Adapters.SQL.query!(TestRepo, """ diff --git a/test/ecto_sqlite3_returning_debug_test.exs b/test/ecto_sqlite3_returning_debug_test.exs index 866f3d7b..bcb360e5 100644 --- a/test/ecto_sqlite3_returning_debug_test.exs +++ b/test/ecto_sqlite3_returning_debug_test.exs @@ -21,7 +21,8 @@ defmodule EctoLibSql.EctoSqlite3ReturningDebugTest do log: :info ) - {:ok, _} = EctoLibSql.Integration.TestRepo.start_link() + # Supervised so ExUnit stops the shared repo before the next module starts it. + start_supervised!(EctoLibSql.Integration.TestRepo) # Run migrations :ok = diff --git a/test/in_expression_comprehensive_test.exs b/test/in_expression_comprehensive_test.exs index e6191f8d..30b5f427 100644 --- a/test/in_expression_comprehensive_test.exs +++ b/test/in_expression_comprehensive_test.exs @@ -35,7 +35,8 @@ defmodule EctoLibSql.InExpressionComprehensiveTest do database: @test_db ) - {:ok, _} = EctoLibSql.Integration.TestRepo.start_link() + # Supervised so ExUnit stops the shared repo before the next module starts it. + start_supervised!(EctoLibSql.Integration.TestRepo) # Create test tables Ecto.Adapters.SQL.query!(TestRepo, """ diff --git a/test/returning_clause_test.exs b/test/returning_clause_test.exs index 8ab05174..07625a34 100644 --- a/test/returning_clause_test.exs +++ b/test/returning_clause_test.exs @@ -28,7 +28,8 @@ defmodule EctoLibSql.ReturningClauseTest do database: @test_db ) - {:ok, _} = EctoLibSql.Integration.TestRepo.start_link() + # Supervised so ExUnit stops the shared repo before the next module starts it. + start_supervised!(EctoLibSql.Integration.TestRepo) # Run migrations. :ok =