test(ha): pin the default gated task key set
This commit is contained in:
@@ -38,6 +38,42 @@ public class ScanLeaderOptionsTests
|
||||
$"Gated keys match no scheduled task: {string.Join(", ", unmatched)}. Known keys: {string.Join(", ", registeredKeys.Order(StringComparer.Ordinal))}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A key dropped from the default set silently un-gates that task on every replica, so the whole
|
||||
/// set is pinned against a hand-maintained expectation rather than read back from the options.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DefaultGatedTaskKeys_Should_BeTheExpectedSet()
|
||||
{
|
||||
string[] expected =
|
||||
{
|
||||
"AudioNormalization",
|
||||
"CleanupUserDataTask",
|
||||
"DownloadLyrics",
|
||||
"DownloadSubtitles",
|
||||
"KeyframeExtraction",
|
||||
"MoveTrickplayImages",
|
||||
"OptimizeDatabaseTask",
|
||||
"PluginUpdates",
|
||||
"RefreshChapterImages",
|
||||
"RefreshGuide",
|
||||
"RefreshInternetChannels",
|
||||
"RefreshLibrary",
|
||||
"RefreshPeople",
|
||||
"RefreshTrickplayImages",
|
||||
"TaskExtractMediaSegments",
|
||||
"TmdbRefreshUpcomingEpisodes"
|
||||
};
|
||||
|
||||
var actual = new ScanLeaderOptions().GatedTaskKeys;
|
||||
var missing = expected.Except(actual, StringComparer.Ordinal).ToList();
|
||||
var unexpected = actual.Except(expected, StringComparer.Ordinal).ToList();
|
||||
|
||||
Assert.True(
|
||||
missing.Count == 0 && unexpected.Count == 0,
|
||||
$"Default gated task keys drifted. Missing: {Describe(missing)}. Unexpected: {Describe(unexpected)}.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The key universe is only as complete as the assemblies it is read from, so a task added to an
|
||||
/// unscanned assembly must fail here rather than narrow what the previous test can catch.
|
||||
@@ -69,6 +105,9 @@ public class ScanLeaderOptionsTests
|
||||
Assert.True(missing.Count == 0, $"Assemblies declaring scheduled tasks but not scanned: {string.Join(", ", missing)}");
|
||||
}
|
||||
|
||||
private static string Describe(IReadOnlyCollection<string> keys)
|
||||
=> keys.Count == 0 ? "none" : string.Join(", ", keys.Order(StringComparer.Ordinal));
|
||||
|
||||
private static HashSet<string> DiscoverScheduledTaskKeys(IEnumerable<Assembly> assemblies)
|
||||
{
|
||||
var keys = new HashSet<string>(StringComparer.Ordinal);
|
||||
|
||||
Reference in New Issue
Block a user