fix(tests): clear the SQLite pool before deleting the secrets path-guard temp dir — Windows sharing violation
This commit is contained in:
@@ -100,7 +100,24 @@ public sealed class SecretsStorePathGuardTests
|
||||
finally
|
||||
{
|
||||
Environment.SetEnvironmentVariable(SqlitePathVariable, original);
|
||||
Directory.Delete(directory, recursive: true);
|
||||
|
||||
// The store runs in WAL mode with connection pooling, so a pooled handle can outlive the
|
||||
// migration and keep secrets.db (plus its -wal/-shm sidecars) open. Windows refuses to
|
||||
// delete a directory holding open files where Unix does not, so clear the pool first;
|
||||
// the catch is belt-and-braces for a sidecar whose handle outlasts even that.
|
||||
Microsoft.Data.Sqlite.SqliteConnection.ClearAllPools();
|
||||
try
|
||||
{
|
||||
Directory.Delete(directory, recursive: true);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
// Best-effort cleanup of the temp store; a locked file must not fail the test.
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
// Best-effort cleanup of the temp store; a locked file must not fail the test.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user