fix: deliver validated AI insight responses

This commit is contained in:
2026-08-22 15:47:38 +08:00
parent ca55c2fb3d
commit 3fba4261ee
68 changed files with 6870 additions and 493 deletions

View File

@@ -0,0 +1,44 @@
package eventcatalog
import (
"encoding/json"
"os"
"testing"
"time"
)
func TestImpactfulBusinessCatalogIsValidAndIndustryPersonalized(t *testing.T) {
data, err := os.ReadFile("../../catalogs/impactful-business-events-1405-v1.json")
if err != nil {
t.Fatal(err)
}
var input Import
if err := json.Unmarshal(data, &input); err != nil {
t.Fatal(err)
}
if err := ValidateImport(input, 1405); err != nil {
t.Fatal(err)
}
hasEducation, hasRetail := false, false
months := make(map[time.Month]bool)
for _, event := range input.Events {
if event.OfficialHoliday && event.RelevanceBPS < 7000 {
t.Fatalf("official holiday %s lacks evidenced business impact", event.ID)
}
for _, category := range event.MerchantCategories {
hasEducation = hasEducation || category == "مراکز آموزشی مجازی"
hasRetail = hasRetail || category == "کیف و کفش فروشی"
}
start, err := time.Parse(time.DateOnly, event.StartDate)
if err != nil {
t.Fatal(err)
}
months[start.Month()] = true
}
if !hasEducation || !hasRetail {
t.Fatal("catalog must include both education- and retail-specific windows")
}
if len(input.Events) < 12 || len(months) < 9 {
t.Fatalf("catalog must provide year-round candidate coverage; got %d events across %d months", len(input.Events), len(months))
}
}