From fe4cd39070cd9f3be06ebd14f61d33ddf61407cf Mon Sep 17 00:00:00 2001 From: Timothy Date: Sat, 27 Jun 2026 14:22:44 +0200 Subject: [PATCH] fix: make filler scheduling tests timezone-independent (fixes #24) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should_Not_Crash_Mid_Roll_{Zero,One}_Chapters passed 'new PlayoutItem()' to AddFiller, whose Start defaults to DateTime.MinValue. The mid-roll Pad path (PlayoutModeSchedulerBase.cs:609) subtracts 'currentMinute' minutes from StartOffset; since StartOffset does ToLocalTime(), a non-zero local offset makes currentMinute non-zero, underflowing DateTimeOffset.MinValue and throwing ArgumentOutOfRangeException. Under UTC the offset is 0 so it stays in range (hence CI was green). Unreachable in production — real playout items never start at MinValue — so this is a test-data artifact, not a product bug. Fix: seed the fixtures with a real Start (startState.CurrentTime.UtcDateTime), matching the convention in the passing AddFiller tests. Verified across UTC, Europe/Brussels, and Asia/Kolkata (+5:30); full Core.Tests now passes under any timezone (484/0). Updated docs/contributing.md §8 per its §10 deviation policy. Co-Authored-By: Claude Opus 4.8 --- .../PlayoutModeSchedulerBaseTests.cs | 18 +++++++++++++++--- docs/contributing.md | 7 +++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ErsatzTV.Core.Tests/Scheduling/PlayoutModeSchedulerBaseTests.cs b/ErsatzTV.Core.Tests/Scheduling/PlayoutModeSchedulerBaseTests.cs index 528b4d303..dc3c9fd9e 100644 --- a/ErsatzTV.Core.Tests/Scheduling/PlayoutModeSchedulerBaseTests.cs +++ b/ErsatzTV.Core.Tests/Scheduling/PlayoutModeSchedulerBaseTests.cs @@ -1,4 +1,4 @@ -using ErsatzTV.Core.Domain; +using ErsatzTV.Core.Domain; using ErsatzTV.Core.Domain.Filler; using ErsatzTV.Core.Interfaces.Scheduling; using ErsatzTV.Core.Scheduling; @@ -57,7 +57,13 @@ public class PlayoutModeSchedulerBaseTests : SchedulerTestBase startState, CollectionEnumerators(scheduleItem, enumerator), scheduleItem, - new PlayoutItem(), + // real start time, not default MinValue: the mid-roll Pad math subtracts minutes, + // which underflows DateTimeOffset.MinValue under a non-UTC local offset (#24) + new PlayoutItem + { + Start = startState.CurrentTime.UtcDateTime, + Finish = startState.CurrentTime.UtcDateTime + }, new List(), new PlayoutBuildWarnings(), _cancellationToken); @@ -110,7 +116,13 @@ public class PlayoutModeSchedulerBaseTests : SchedulerTestBase startState, enumerators, scheduleItem, - new PlayoutItem(), + // real start time, not default MinValue: the mid-roll Pad math subtracts minutes, + // which underflows DateTimeOffset.MinValue under a non-UTC local offset (#24) + new PlayoutItem + { + Start = startState.CurrentTime.UtcDateTime, + Finish = startState.CurrentTime.UtcDateTime + }, new List { new() }, new PlayoutBuildWarnings(), _cancellationToken); diff --git a/docs/contributing.md b/docs/contributing.md index 33977d08f..3638a69f8 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -118,8 +118,11 @@ exceptions for control flow. string — `ErsatzTV.FFmpeg.Tests/PipelineBuilderBaseTests.cs`); **golden-file tests** for Jellyfin-facing output (`ErsatzTV.Core.Tests/Iptv/ChannelPlaylistGoldenTests.cs`, regen via `ETV_UPDATE_GOLDENS=1`, ersatztv#11); **architecture tests** (§1, ersatztv#12). -- Run local tests with **`TZ=UTC`** to match CI (a couple of `DateTimeOffset` scheduling tests are - timezone-sensitive — ersatztv#24). CI uses `dotnet test … --blame-hang-timeout 2m`. +- The suite is **timezone-independent** — the previously timezone-sensitive `DateTimeOffset` + filler-scheduling tests were fixed (ersatztv#24) by giving fixtures realistic times instead of the + default `DateTime.MinValue`, which underflowed `DateTimeOffset.MinValue` under a non-UTC offset. + When constructing test `PlayoutItem`s, set a real `Start` (e.g. `startState.CurrentTime.UtcDateTime`), + not the default. CI runs UTC and uses `dotnet test … --blame-hang-timeout 2m`. ## 9. Build / CI