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.Hosting;
|
||||||
using Microsoft.AspNetCore.Mvc.Testing;
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.Data.Sqlite;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace backend.tests;
|
namespace backend.tests;
|
||||||
|
|
||||||
@@ -27,7 +24,11 @@ public class ApiFactory : WebApplicationFactory<Program>
|
|||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
if (File.Exists(_dbPath))
|
SqliteConnection.ClearAllPools();
|
||||||
File.Delete(_dbPath);
|
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