From b8c6c7d432548fd7270924e757ae9406e197cae2 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sun, 19 Jul 2026 08:54:54 -0400 Subject: [PATCH] test(secrets-cli): clean up temp dirs in TargetConfigReaderTests --- .../Cli/Interactive/TargetConfigReaderTests.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ZB.MOM.WW.Secrets/tests/ZB.MOM.WW.Secrets.Tests/Cli/Interactive/TargetConfigReaderTests.cs b/ZB.MOM.WW.Secrets/tests/ZB.MOM.WW.Secrets.Tests/Cli/Interactive/TargetConfigReaderTests.cs index 5682cca..6d1b573 100644 --- a/ZB.MOM.WW.Secrets/tests/ZB.MOM.WW.Secrets.Tests/Cli/Interactive/TargetConfigReaderTests.cs +++ b/ZB.MOM.WW.Secrets/tests/ZB.MOM.WW.Secrets.Tests/Cli/Interactive/TargetConfigReaderTests.cs @@ -8,12 +8,26 @@ namespace ZB.MOM.WW.Secrets.Tests.Cli.Interactive; /// (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. /// -public sealed class TargetConfigReaderTests +public sealed class TargetConfigReaderTests : IDisposable { - private static string NewTempDir() + private readonly List _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")); Directory.CreateDirectory(dir); + _tempDirs.Add(dir); return dir; }