Add collected and derived fact contracts
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/weatherreporter/internal/facts"
|
||||
"gitea.maximumdirect.net/eric/weatherreporter/internal/forecast"
|
||||
"gitea.maximumdirect.net/eric/weatherreporter/internal/report"
|
||||
"gitea.maximumdirect.net/eric/weatherreporter/internal/weatherdata"
|
||||
)
|
||||
@@ -62,7 +64,7 @@ func TestStormBriefingWithActiveAlert(t *testing.T) {
|
||||
Sources: []weatherdata.Source{{Name: "hourly", FetchedAt: time.Now()}},
|
||||
}
|
||||
|
||||
pkg, err := BuildStorm(BuildContext{Resolved: resolved, Bundle: bundle, Units: "us", Timezone: "America/Chicago"})
|
||||
pkg, err := BuildStorm(BuildContext{Resolved: resolved, Bundle: bundle, Units: "us", Timezone: "America/Chicago"}, stormDerivedFacts(t, resolved, bundle))
|
||||
if err != nil {
|
||||
t.Fatalf("BuildStorm() error = %v", err)
|
||||
}
|
||||
@@ -120,7 +122,7 @@ func TestStormBriefingWithDiscussionButNoAlert(t *testing.T) {
|
||||
Sources: []weatherdata.Source{{Name: "hourly", FetchedAt: time.Now()}},
|
||||
}
|
||||
|
||||
pkg, err := BuildStorm(BuildContext{Resolved: resolved, Bundle: bundle, Units: "us", Timezone: "America/Chicago"})
|
||||
pkg, err := BuildStorm(BuildContext{Resolved: resolved, Bundle: bundle, Units: "us", Timezone: "America/Chicago"}, stormDerivedFacts(t, resolved, bundle))
|
||||
if err != nil {
|
||||
t.Fatalf("BuildStorm() error = %v", err)
|
||||
}
|
||||
@@ -155,7 +157,7 @@ func TestStormBriefingQuietWindow(t *testing.T) {
|
||||
Sources: []weatherdata.Source{{Name: "hourly", FetchedAt: time.Now()}},
|
||||
}
|
||||
|
||||
pkg, err := BuildStorm(BuildContext{Resolved: resolved, Bundle: bundle, Units: "us", Timezone: "America/Chicago"})
|
||||
pkg, err := BuildStorm(BuildContext{Resolved: resolved, Bundle: bundle, Units: "us", Timezone: "America/Chicago"}, stormDerivedFacts(t, resolved, bundle))
|
||||
if err != nil {
|
||||
t.Fatalf("BuildStorm() error = %v", err)
|
||||
}
|
||||
@@ -167,3 +169,17 @@ func TestStormBriefingQuietWindow(t *testing.T) {
|
||||
t.Fatalf("WhatToWatchNext = %#v, want watch fallback", pkg.Storm.WhatToWatchNext)
|
||||
}
|
||||
}
|
||||
|
||||
func stormDerivedFacts(t *testing.T, resolved report.Resolved, bundle *weatherdata.Bundle) facts.DerivedFacts {
|
||||
t.Helper()
|
||||
derived, err := facts.BuildDerived(facts.BuildDerivedRequest{
|
||||
Resolved: resolved,
|
||||
Timezone: "America/Chicago",
|
||||
Dayparts: []forecast.DaypartDefinition{{Name: "morning", Start: "06:00", End: "12:00"}},
|
||||
Collected: facts.BuildCollected(bundle),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("build derived facts: %v", err)
|
||||
}
|
||||
return derived
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user