package summary import ( "testing" "time" "ccp/internal/store" ) func TestEvaluate(t *testing.T) { totals := []store.Total{ {Kind: "tab_focus", Label: "youtube.com", Seconds: 5400}, {Kind: "tab_focus", Label: "github.com", Seconds: 1800}, {Kind: "walk", Label: "Outdoor Walk", Seconds: 1200}, } goals := []store.Goal{ {ID: 1, Kind: "tab_focus", Label: "youtube.com", Op: "<=", TargetS: 3600}, {ID: 2, Kind: "walk", Op: ">=", TargetS: 1800}, {ID: 3, Kind: "tab_focus", Op: ">=", TargetS: 7200}, // empty label = all labels } got := Evaluate(totals, goals) want := []struct { actual int64 met bool }{{5400, false}, {1200, false}, {7200, true}} for i, w := range want { if got[i].ActualS != w.actual || got[i].Met != w.met { t.Errorf("goal %d: got actual=%d met=%v, want %+v", goals[i].ID, got[i].ActualS, got[i].Met, w) } } } func TestDayBoundsDST(t *testing.T) { loc, err := time.LoadLocation("America/New_York") if err != nil { t.Skip("no tzdata:", err) } // 2026-03-08 is the spring-forward day: only 23 hours long. from, to := DayBounds(time.Date(2026, 3, 8, 15, 0, 0, 0, loc), loc) if to.Sub(from) != 23*time.Hour || from.Hour() != 0 { t.Fatalf("got %v - %v", from, to) } }