This commit is contained in:
@@ -45,3 +45,47 @@ func TestNextIntervalAutoAtSchedulesAfterCurrentCompletion(t *testing.T) {
|
||||
t.Fatalf("nextIntervalAutoAt() = %s, want %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsEmptySuccessRunRequiresConfiguredZeroMetrics(t *testing.T) {
|
||||
stats := map[string]any{
|
||||
"hydrated_count": 0,
|
||||
"claimed_count": 0,
|
||||
}
|
||||
config := map[string]any{
|
||||
"suppress_empty_success_runs": true,
|
||||
"empty_success_metric_keys": []any{"hydrated_count", "claimed_count"},
|
||||
}
|
||||
|
||||
if !isEmptySuccessRun(stats, config) {
|
||||
t.Fatal("expected empty success run to be suppressed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsEmptySuccessRunKeepsRunsWithOutput(t *testing.T) {
|
||||
stats := map[string]any{
|
||||
"recoverable_count": 1,
|
||||
"republished_count": 0,
|
||||
}
|
||||
config := map[string]any{
|
||||
"suppress_empty_success_runs": true,
|
||||
"empty_success_metric_keys": []any{"recoverable_count", "republished_count"},
|
||||
}
|
||||
|
||||
if isEmptySuccessRun(stats, config) {
|
||||
t.Fatal("expected non-empty success run to be retained")
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldSuppressEmptySuccessRunOnlyForAutoNonDryRun(t *testing.T) {
|
||||
config := map[string]any{"suppress_empty_success_runs": true}
|
||||
|
||||
if !shouldSuppressEmptySuccessRun("auto", false, config) {
|
||||
t.Fatal("expected auto non-dry-run to allow suppression")
|
||||
}
|
||||
if shouldSuppressEmptySuccessRun("manual", false, config) {
|
||||
t.Fatal("manual runs must not be suppressed")
|
||||
}
|
||||
if shouldSuppressEmptySuccessRun("auto", true, config) {
|
||||
t.Fatal("dry runs must not be suppressed")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user