Add near-term report config overrides
This commit is contained in:
@@ -181,9 +181,9 @@ snapshot exists and a threshold is crossed.
|
||||
`reports` optionally overrides the ordered deterministic modules declared by
|
||||
report definitions. Omit a report entry to use its default module order.
|
||||
|
||||
Supported report keys are `daily`, `tomorrow`, `three_day`, `weekend`, and
|
||||
`storm`. Canonical report IDs such as `daily_today` and `daily_tomorrow` are
|
||||
also accepted.
|
||||
Supported report keys are `daily`, `tomorrow`, `near_term`, `near-term`,
|
||||
`three_day`, `weekend`, and `storm`. Canonical report IDs such as
|
||||
`daily_today` and `daily_tomorrow` are also accepted.
|
||||
|
||||
Each report entry supports:
|
||||
|
||||
|
||||
@@ -161,6 +161,45 @@ reports:
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadNearTermReportModuleOverrides(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
key string
|
||||
}{
|
||||
{name: "UnderscoreAlias", key: "near_term"},
|
||||
{name: "HyphenAlias", key: "near-term"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
path := writeConfig(t, `
|
||||
reports:
|
||||
`+tt.key+`:
|
||||
deterministic_modules:
|
||||
- metadata
|
||||
- hourly_forecast
|
||||
- precip_timing
|
||||
- alert_digest
|
||||
`)
|
||||
|
||||
cfg, err := LoadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadFile() error = %v", err)
|
||||
}
|
||||
overrides := cfg.ReportModuleOverrides()
|
||||
items := overrides[report.NearTerm]
|
||||
if len(items) != 4 {
|
||||
t.Fatalf("near-term override length = %d, want 4", len(items))
|
||||
}
|
||||
if items[0].ID != module.Metadata ||
|
||||
items[1].ID != module.HourlyForecast ||
|
||||
items[2].ID != module.PrecipTiming ||
|
||||
items[3].ID != module.AlertDigest {
|
||||
t.Fatalf("near-term override = %#v, want configured module order", items)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportModuleOverrideValidation(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -244,6 +283,29 @@ reports:
|
||||
`,
|
||||
wantErr: "duplicates report override",
|
||||
},
|
||||
{
|
||||
name: "DuplicateNearTermAlias",
|
||||
yaml: `
|
||||
reports:
|
||||
near_term:
|
||||
deterministic_modules:
|
||||
- metadata
|
||||
near-term:
|
||||
deterministic_modules:
|
||||
- current_conditions
|
||||
`,
|
||||
wantErr: "duplicates report override",
|
||||
},
|
||||
{
|
||||
name: "NearTermIncompatibleDailyModule",
|
||||
yaml: `
|
||||
reports:
|
||||
near_term:
|
||||
deterministic_modules:
|
||||
- derived_daily_summary
|
||||
`,
|
||||
wantErr: `not compatible with report "near_term"`,
|
||||
},
|
||||
{
|
||||
name: "UnknownReportField",
|
||||
yaml: `
|
||||
|
||||
@@ -113,6 +113,8 @@ func reportIDForConfigKey(key string) (report.ID, error) {
|
||||
return report.DailyToday, nil
|
||||
case "tomorrow", "daily_tomorrow":
|
||||
return report.DailyTomorrow, nil
|
||||
case "near_term":
|
||||
return report.NearTerm, nil
|
||||
case "three_day", "three_day_outlook":
|
||||
return report.ThreeDay, nil
|
||||
case "weekend", "weekend_outlook":
|
||||
|
||||
Reference in New Issue
Block a user