From 56f9ad3706505268f0e8ce7e72260dc8e4c8e9f0 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 23 Nov 2026 16:00:31 +0000 Subject: [PATCH] Preserve the shared SQLite schema while resetting --- CHANGELOG.md | 2 ++ .../Yavsc.Api.Tests/Fixtures/ApiWebServerFixture.cs | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dcf4a68f..6d12a4791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ ### Fixed +* [Yavsc.Api/Tests] Preserve the shared SQLite schema while resetting API integration-test data, preventing hosted workers from observing missing `LiveFlow` tables during test-host shutdown. + * [PostIt/Blogs] Keep a newly created post readable when its creation response temporarily omits author details, and include the author in server-side create/detail payloads so relative resource URLs can be resolved after save. * [PostIt/Capture] Automatically upload finalized screen recordings as `video/mp4` to `Mes fichiers / screencast`, streaming the multipart file from disk and retaining the local copy if the upload fails. diff --git a/src/test/Yavsc.Api.Tests/Fixtures/ApiWebServerFixture.cs b/src/test/Yavsc.Api.Tests/Fixtures/ApiWebServerFixture.cs index 8b1a5fcf5..59f74526e 100644 --- a/src/test/Yavsc.Api.Tests/Fixtures/ApiWebServerFixture.cs +++ b/src/test/Yavsc.Api.Tests/Fixtures/ApiWebServerFixture.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.Extensions.DependencyInjection; @@ -377,7 +376,10 @@ public sealed class ApiWebServerFixture : WebHostFixture return; } - // EnsureDeleted cannot clear a shared in-memory database kept alive by the anchor. + // Keep the schema in place while the hosted workers are running. Dropping and + // recreating every table exposes a race where a worker queries LiveFlow + // between those operations and faults; Host.StopAsync later rethrows that + // fault when the shared test host shuts down. db.Database.OpenConnection(); try { @@ -397,9 +399,11 @@ public sealed class ApiWebServerFixture : WebHostFixture command.Transaction = transaction.GetDbTransaction(); foreach (var table in tables) { - command.CommandText = $"DROP TABLE \"{table.Replace("\"", "\"\"")}\";"; + command.CommandText = $"DELETE FROM \"{table.Replace("\"", "\"\"")}\";"; command.ExecuteNonQuery(); } + command.CommandText = "DELETE FROM sqlite_sequence;"; + command.ExecuteNonQuery(); transaction.Commit(); } finally @@ -413,8 +417,6 @@ public sealed class ApiWebServerFixture : WebHostFixture { db.Database.CloseConnection(); } - // SQLite retains sqlite_sequence, so EnsureCreated would incorrectly see an existing schema. - db.GetService().CreateTables(); } public void ResetAndSeedRdvQueryGraph()