Consolidate generated text test ownership

This commit is contained in:
2026-08-13 04:22:33 +00:00
parent d6829af32b
commit b985c5faac
8 changed files with 109 additions and 681 deletions

View File

@@ -119,6 +119,57 @@ func TestValidateDayStyleGeneratedTextSharedBehavior(t *testing.T) {
}
}
func TestDayStyleValidatorsReturnReportSpecificTypes(t *testing.T) {
tests := []struct {
name string
validate func([]byte) (any, error)
matches func(any) bool
}{
{
name: "daily",
validate: func(data []byte) (any, error) {
return ValidateDaily(data)
},
matches: func(value any) bool {
_, ok := value.(Daily)
return ok
},
},
{
name: "today",
validate: func(data []byte) (any, error) {
return ValidateToday(data)
},
matches: func(value any) bool {
_, ok := value.(Today)
return ok
},
},
{
name: "tomorrow",
validate: func(data []byte) (any, error) {
return ValidateTomorrow(data)
},
matches: func(value any) bool {
_, ok := value.(Tomorrow)
return ok
},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
value, err := test.validate([]byte(`{"summary":"Summary.","forecast_discussion":["Discussion."],"precipitation_timing":""}`))
if err != nil {
t.Fatalf("validate() error = %v", err)
}
if !test.matches(value) {
t.Fatalf("validate() type = %T, want %s generated text", value, test.name)
}
})
}
}
func dayStyleFieldsForTest(t *testing.T, value any) dayStyleFields {
t.Helper()