From de63603aab658e5d254bbcc0213f439d377e1a01 Mon Sep 17 00:00:00 2001 From: Timothy Date: Fri, 17 Jul 2026 20:03:10 +0200 Subject: [PATCH] test(320): don't blanket-delete foreign *.ts in the shared troubleshooting folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-review nit: the regression test deleted every *.ts in the machine-global TranscodeTroubleshootingFolder, which could nuke a live troubleshooting session's segments on a dev machine (reaping files it didn't create). Drop the sweep and keep only Directory.CreateDirectory — the folder-exists guarantee is what closes the false-pass hole; NUnit runs serially and no test leaves >= 2 stray .ts, so determinism is unaffected (negative control re-verified: still fails in ~10s). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Controllers/TroubleshootControllerTests.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ErsatzTV.Tests/Controllers/TroubleshootControllerTests.cs b/ErsatzTV.Tests/Controllers/TroubleshootControllerTests.cs index bf0278db0..0ceb3ce42 100644 --- a/ErsatzTV.Tests/Controllers/TroubleshootControllerTests.cs +++ b/ErsatzTV.Tests/Controllers/TroubleshootControllerTests.cs @@ -456,15 +456,14 @@ public class TroubleshootControllerTests // cancels (which would tie up the request thread + hold the troubleshooting lock). // // The segment scan uses the real Directory.GetFiles on the shared troubleshooting folder, so - // to make the pre-fix spin path deterministic (regardless of NUnit run order) we seed an EMPTY - // folder: it must exist (else Directory.GetFiles throws -> fast 404 -> false pass) and hold - // fewer than initialSegmentCount .ts files (so hasSegments never trips). With that guaranteed, - // the only thing that lets the fixed code complete before the cancellation deadline is IsFailed. + // ensure the folder EXISTS — otherwise Directory.GetFiles throws DirectoryNotFoundException, + // which the pre-fix loop would surface as a fast 404 (a false pass that hides the regression). + // We deliberately do NOT delete stray *.ts here: this folder is machine-global and may hold a + // live troubleshooting session's segments (don't reap files this test didn't create). It isn't + // needed for determinism — NUnit runs serially and the sibling Should_Return_200 test cleans up + // its own seg-test-*.ts in a finally, so no test leaves >= initialSegmentCount(2) files behind; + // and the fixed code breaks on IsFailed before the scan runs regardless of folder contents. Directory.CreateDirectory(FileSystemLayout.TranscodeTroubleshootingFolder); - foreach (string stray in Directory.GetFiles(FileSystemLayout.TranscodeTroubleshootingFolder, "*.ts")) - { - File.Delete(stray); - } _entityLocker.IsTroubleshootingPlaybackLocked().Returns(false);