Fix: clean up SQLite WAL/SHM sidecars in ApiFactory.Dispose

This commit is contained in:
2026-06-11 18:22:33 +00:00
parent f2bb2d984b
commit 824a27520d
+7 -6
View File
@@ -1,10 +1,7 @@
using System.IO;
using backend.Data;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.EntityFrameworkCore;
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace backend.tests;
@@ -27,7 +24,11 @@ public class ApiFactory : WebApplicationFactory<Program>
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (File.Exists(_dbPath))
File.Delete(_dbPath);
SqliteConnection.ClearAllPools();
foreach (var suffix in new[] { "", "-shm", "-wal", "-journal" })
{
var p = _dbPath + suffix;
try { if (File.Exists(p)) File.Delete(p); } catch { /* best effort */ }
}
}
}