package marketing import ( "strings" "testing" ) func TestListPreparedCampaignsSQL_boundsAndFilters(t *testing.T) { if !strings.Contains(listPreparedCampaignsSQL, "LIMIT") { t.Fatal("expected SQL LIMIT on prepared campaigns list") } if !strings.Contains(listPreparedCampaignsSQL, "template ?") { t.Fatal("expected jsonb key filter so non-campaign feeds are skipped in SQL") } if maxPreparedCampaigns <= 0 || maxPreparedCampaigns > 2000 { t.Fatalf("maxPreparedCampaigns out of expected range: %d", maxPreparedCampaigns) } } func TestBlackFridayDate2026(t *testing.T) { bf := BlackFridayDate(2026) if bf.Year() != 2026 || bf.Month() != 11 || bf.Day() != 27 { t.Fatalf("expected 2026-11-27, got %s", bf.Format("2006-01-02")) } } func TestResolveBlackFridayWindow(t *testing.T) { p, err := ResolvePreset(PresetBlackFriday, 2026) if err != nil { t.Fatal(err) } if p.StartDate != "2026-11-20" || p.EndDate != "2026-11-30" { t.Fatalf("unexpected window %s → %s", p.StartDate, p.EndDate) } } func TestResolveChristmas(t *testing.T) { p, err := ResolvePreset(PresetChristmas, 2026) if err != nil { t.Fatal(err) } if p.StartDate != "2026-12-01" || p.EndDate != "2026-12-26" { t.Fatalf("unexpected christmas window %s → %s", p.StartDate, p.EndDate) } } func TestComputeProductQualityScore(t *testing.T) { empty := ComputeProductQualityScore(ProductInput{}) if empty.Score != 0 || empty.Grade != "F" { t.Fatalf("empty expected F/0, got %s/%d", empty.Grade, empty.Score) } full := ComputeProductQualityScore(ProductInput{ ProcessedName: "Great Widget Pro", ProcessedDescription: "A detailed product description that is long enough.", MetaTitle: "Great Widget Pro | Shop", MetaDescription: "Buy Great Widget Pro with free shipping and a two-year warranty today.", Category: "Widgets", ProcessedAttributes: map[string]any{"color": "red"}, MappedData: map[string]any{"image": "https://example.com/w.jpg"}, }) if full.Score != 100 || full.Grade != "A" { t.Fatalf("full expected A/100, got %s/%d", full.Grade, full.Score) } }