test(secrets-cli): clean up temp dirs in TargetConfigReaderTests
This commit is contained in:
+16
-2
@@ -8,12 +8,26 @@ namespace ZB.MOM.WW.Secrets.Tests.Cli.Interactive;
|
|||||||
/// (base json + optional environment overlay + environment variables) exactly the way the app
|
/// (base json + optional environment overlay + environment variables) exactly the way the app
|
||||||
/// would at startup, so fixes land in the store the app actually reads.
|
/// would at startup, so fixes land in the store the app actually reads.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class TargetConfigReaderTests
|
public sealed class TargetConfigReaderTests : IDisposable
|
||||||
{
|
{
|
||||||
private static string NewTempDir()
|
private readonly List<string> _tempDirs = [];
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
foreach (string dir in _tempDirs)
|
||||||
|
{
|
||||||
|
if (Directory.Exists(dir))
|
||||||
|
{
|
||||||
|
try { Directory.Delete(dir, recursive: true); } catch (IOException) { /* best-effort temp cleanup */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string NewTempDir()
|
||||||
{
|
{
|
||||||
string dir = Path.Combine(Path.GetTempPath(), "zb-secrets-cfg-" + Guid.NewGuid().ToString("N"));
|
string dir = Path.Combine(Path.GetTempPath(), "zb-secrets-cfg-" + Guid.NewGuid().ToString("N"));
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
|
_tempDirs.Add(dir);
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user