52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package spc
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestRawConvectiveOutlookBundleJSONShape(t *testing.T) {
|
|
fetchedAt := time.Date(2026, 6, 11, 20, 0, 0, 0, time.UTC)
|
|
bundle := RawConvectiveOutlookBundle{
|
|
LocationID: "stl",
|
|
LocationName: "St. Louis, MO",
|
|
Latitude: 38.6239,
|
|
Longitude: -90.3571,
|
|
FetchedAt: fetchedAt,
|
|
Products: []RawOutlookProduct{{
|
|
Key: "day1_categorical",
|
|
Day: 1,
|
|
OutlookType: OutlookTypeCategorical,
|
|
URL: "https://example.invalid/day1.geojson",
|
|
FetchedAt: fetchedAt,
|
|
Body: json.RawMessage(`{"type":"FeatureCollection","features":[]}`),
|
|
}},
|
|
Discussions: []RawDiscussionPage{{
|
|
Key: "day1",
|
|
Day: 1,
|
|
URL: "https://example.invalid/day1.html",
|
|
FetchedAt: fetchedAt,
|
|
Body: "Day 1 Convective Outlook",
|
|
}},
|
|
}
|
|
|
|
raw, err := json.Marshal(bundle)
|
|
if err != nil {
|
|
t.Fatalf("Marshal() error = %v", err)
|
|
}
|
|
|
|
var got map[string]any
|
|
if err := json.Unmarshal(raw, &got); err != nil {
|
|
t.Fatalf("Unmarshal() error = %v", err)
|
|
}
|
|
for _, key := range []string{"locationId", "locationName", "latitude", "longitude", "fetchedAt", "products", "discussions"} {
|
|
if _, ok := got[key]; !ok {
|
|
t.Fatalf("marshaled bundle missing key %q in %s", key, raw)
|
|
}
|
|
}
|
|
if _, ok := got["rss"]; ok {
|
|
t.Fatalf("marshaled bundle included empty rss: %s", raw)
|
|
}
|
|
}
|