package domain import ( "testing" "time" ) func TestNormalizeSweepHours(t *testing.T) { got, err := NormalizeSweepHours(nil) if err != nil { t.Fatal(err) } if len(got) != 1 || got[0] != 6 { t.Fatalf("empty → default [6], got %v", got) } got, err = NormalizeSweepHours([]int{18, 6, 6, 12}) if err != nil { t.Fatal(err) } if len(got) != 3 || got[0] != 6 || got[1] != 12 || got[2] != 18 { t.Fatalf("dedupe+sort, got %v", got) } if _, err := NormalizeSweepHours([]int{24}); err == nil { t.Fatal("hour 24 should fail") } if _, err := NormalizeSweepHours([]int{0, 3, 6, 9, 12, 15, 18}); err == nil { t.Fatal("too many hours should fail") } } func TestDueSweepSlots_TaipeiHours(t *testing.T) { loc := TaipeiLocation() // 05:59 Taipei 31 Jul → no 06:00 slot yet before := time.Date(2026, 7, 31, 5, 59, 0, 0, loc) if slots := DueSweepSlots(before, []int{6, 18}); len(slots) != 0 { t.Fatalf("before 06:00 want 0, got %+v", slots) } at := time.Date(2026, 7, 31, 6, 0, 0, 0, loc) slots := DueSweepSlots(at, []int{6, 18}) if len(slots) != 1 || slots[0].Hour != 6 { t.Fatalf("at 06:00 want [6], got %+v", slots) } evening := time.Date(2026, 7, 31, 18, 5, 0, 0, loc) slots = DueSweepSlots(evening, []int{6, 18}) if len(slots) != 2 || slots[0].Hour != 6 || slots[1].Hour != 18 { t.Fatalf("after 18:00 want [6,18], got %+v", slots) } }