32 lines
1.8 KiB
Go
32 lines
1.8 KiB
Go
package growth
|
|
|
|
import "testing"
|
|
|
|
func testCatalog() []Event {
|
|
category := []string{"مراکز آموزشی مجازی", "کیف و کفش فروشی"}
|
|
return []Event{
|
|
{ID: "history", TitleFA: "رویداد تاریخی", StartDate: date("2026-01-03"), EndDate: date("2026-01-03"), Family: "history", Tags: []string{"history"}, Source: "test", SourceVersion: "1", Kind: EventOfficial, Universal: true},
|
|
{ID: "back-to-school-1405", TitleFA: "بازگشایی", StartDate: date("2026-09-10"), EndDate: date("2026-09-22"), Family: "education", Tags: []string{"education"}, Source: "test", SourceVersion: "1", Categories: category, Kind: EventCommercial},
|
|
{ID: "autumn-opening-1405", TitleFA: "پاییز", StartDate: date("2026-09-23"), EndDate: date("2026-09-28"), Family: "seasonal", Tags: []string{"seasonal"}, Source: "test", SourceVersion: "1", Categories: category, Kind: EventCommercial},
|
|
{ID: "halloween-2026", TitleFA: "هالووین", StartDate: date("2026-10-31"), EndDate: date("2026-10-31"), Family: "commercial", Tags: []string{"campaign"}, Source: "test", SourceVersion: "1", Categories: category, Kind: EventCommercial},
|
|
{ID: "black-friday-2026", TitleFA: "بلکفرایدی", StartDate: date("2026-11-27"), EndDate: date("2026-11-27"), Family: "commercial", Tags: []string{"campaign"}, Source: "test", SourceVersion: "1", Categories: category, Kind: EventCommercial},
|
|
}
|
|
}
|
|
|
|
func TestValidateCatalogRejectsDuplicateAndIncompleteEvents(t *testing.T) {
|
|
event := testCatalog()[0]
|
|
if err := ValidateCatalog([]Event{event, event}); err == nil {
|
|
t.Fatal("expected duplicate id error")
|
|
}
|
|
event.Source = ""
|
|
if err := ValidateCatalog([]Event{event}); err == nil {
|
|
t.Fatal("expected missing source error")
|
|
}
|
|
}
|
|
|
|
func TestDatabaseMappedCatalogCanBeValidated(t *testing.T) {
|
|
if err := ValidateCatalog(testCatalog()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|