Fix: clean up SQLite WAL/SHM sidecars in ApiFactory.Dispose
This commit is contained in:
@@ -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 */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user