|
|
|
|
@@ -12,39 +12,39 @@ import (
|
|
|
|
|
"gitea.maximumdirect.net/eric/weatherreporter/internal/weatherdata"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestPlanBatchReportsMorningOrder(t *testing.T) {
|
|
|
|
|
func TestPlanBatchRunMorningOrder(t *testing.T) {
|
|
|
|
|
location := mustLoadTestLocation(t, "America/Chicago")
|
|
|
|
|
hourly := hourlyRun(fullDayPeriods(t, "2026-05-31", location)...)
|
|
|
|
|
|
|
|
|
|
planned, err := planBatchReports(BatchRequest{Config: planningConfig(), Batch: BatchMorning}, mustParse("2026-05-29T08:00:00-05:00"), collectionWithHourly(hourly))
|
|
|
|
|
planned, err := planBatchRun(BatchRequest{Config: planningConfig(), Batch: BatchMorning}, mustParse("2026-05-29T08:00:00-05:00"), collectionWithHourly(hourly))
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("planBatchReports() error = %v", err)
|
|
|
|
|
t.Fatalf("planBatchRun() error = %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertPlannedReportIDs(t, planned, report.Today, report.Tomorrow, report.Daily)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPlanBatchReportsEveningOrder(t *testing.T) {
|
|
|
|
|
func TestPlanBatchRunEveningOrder(t *testing.T) {
|
|
|
|
|
location := mustLoadTestLocation(t, "America/Chicago")
|
|
|
|
|
hourly := hourlyRun(fullDayPeriods(t, "2026-05-31", location)...)
|
|
|
|
|
|
|
|
|
|
planned, err := planBatchReports(BatchRequest{Config: planningConfig(), Batch: BatchEvening}, mustParse("2026-05-29T18:00:00-05:00"), collectionWithHourly(hourly))
|
|
|
|
|
planned, err := planBatchRun(BatchRequest{Config: planningConfig(), Batch: BatchEvening}, mustParse("2026-05-29T18:00:00-05:00"), collectionWithHourly(hourly))
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("planBatchReports() error = %v", err)
|
|
|
|
|
t.Fatalf("planBatchRun() error = %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertPlannedReportIDs(t, planned, report.Tomorrow, report.Daily)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPlanBatchReportsDynamicDailyDatesStartAfterTomorrow(t *testing.T) {
|
|
|
|
|
func TestPlanBatchRunDynamicDailyDatesStartAfterTomorrow(t *testing.T) {
|
|
|
|
|
location := mustLoadTestLocation(t, "America/Chicago")
|
|
|
|
|
periods := fullDayPeriods(t, "2026-05-30", location)
|
|
|
|
|
periods = append(periods, fullDayPeriods(t, "2026-05-31", location)...)
|
|
|
|
|
periods = append(periods, fullDayPeriods(t, "2026-06-01", location)...)
|
|
|
|
|
|
|
|
|
|
planned, err := planBatchReports(BatchRequest{Config: planningConfig(), Batch: BatchMorning}, mustParse("2026-05-29T08:00:00-05:00"), collectionWithHourly(hourlyRun(periods...)))
|
|
|
|
|
planned, err := planBatchRun(BatchRequest{Config: planningConfig(), Batch: BatchMorning}, mustParse("2026-05-29T08:00:00-05:00"), collectionWithHourly(hourlyRun(periods...)))
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("planBatchReports() error = %v", err)
|
|
|
|
|
t.Fatalf("planBatchRun() error = %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
daily := plannedDailyReports(planned)
|
|
|
|
|
@@ -55,10 +55,10 @@ func TestPlanBatchReportsDynamicDailyDatesStartAfterTomorrow(t *testing.T) {
|
|
|
|
|
assertPlanningPeriod(t, daily[1].Resolved.ValidPeriod, "2026-06-01T00:00:00-05:00", "2026-06-02T00:00:00-05:00")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPlanBatchReportsMorningExcludesLegacyStaticReports(t *testing.T) {
|
|
|
|
|
planned, err := planBatchReports(BatchRequest{Config: planningConfig(), Batch: BatchMorning}, mustParse("2026-05-29T08:00:00-05:00"), collect.Result{Bundle: &weatherdata.Bundle{}})
|
|
|
|
|
func TestPlanBatchRunMorningExcludesLegacyStaticReports(t *testing.T) {
|
|
|
|
|
planned, err := planBatchRun(BatchRequest{Config: planningConfig(), Batch: BatchMorning}, mustParse("2026-05-29T08:00:00-05:00"), collect.Result{Bundle: &weatherdata.Bundle{}})
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("planBatchReports() error = %v", err)
|
|
|
|
|
t.Fatalf("planBatchRun() error = %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, item := range planned {
|
|
|
|
|
@@ -68,13 +68,13 @@ func TestPlanBatchReportsMorningExcludesLegacyStaticReports(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPlanBatchReportsDynamicDailyOutputCopyNames(t *testing.T) {
|
|
|
|
|
func TestPlanBatchRunDynamicDailyOutputCopyNames(t *testing.T) {
|
|
|
|
|
location := mustLoadTestLocation(t, "America/Chicago")
|
|
|
|
|
hourly := hourlyRun(fullDayPeriods(t, "2026-05-31", location)...)
|
|
|
|
|
|
|
|
|
|
planned, err := planBatchReports(BatchRequest{Config: planningConfig(), Batch: BatchEvening}, mustParse("2026-05-29T18:00:00-05:00"), collectionWithHourly(hourly))
|
|
|
|
|
planned, err := planBatchRun(BatchRequest{Config: planningConfig(), Batch: BatchEvening}, mustParse("2026-05-29T18:00:00-05:00"), collectionWithHourly(hourly))
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("planBatchReports() error = %v", err)
|
|
|
|
|
t.Fatalf("planBatchRun() error = %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
daily := plannedDailyReports(planned)
|
|
|
|
|
@@ -89,10 +89,10 @@ func TestPlanBatchReportsDynamicDailyOutputCopyNames(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPlanBatchReportsRejectsUnknownBatch(t *testing.T) {
|
|
|
|
|
_, err := planBatchReports(BatchRequest{Config: planningConfig(), Batch: BatchKind("hourly")}, mustParse("2026-05-29T08:00:00-05:00"), collect.Result{Bundle: &weatherdata.Bundle{}})
|
|
|
|
|
func TestPlanBatchRunRejectsUnknownBatch(t *testing.T) {
|
|
|
|
|
_, err := planBatchRun(BatchRequest{Config: planningConfig(), Batch: BatchKind("hourly")}, mustParse("2026-05-29T08:00:00-05:00"), collect.Result{Bundle: &weatherdata.Bundle{}})
|
|
|
|
|
if err == nil || !strings.Contains(err.Error(), `unknown batch command "hourly"`) {
|
|
|
|
|
t.Fatalf("planBatchReports() error = %v, want unknown batch command", err)
|
|
|
|
|
t.Fatalf("planBatchRun() error = %v, want unknown batch command", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|