package dashboard import ( "testing" "time" ) func TestFillTrendSeriesIncludesZeroDays(t *testing.T) { now := time.Now().UTC() end := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC) mid := end.AddDate(0, 0, -1).Format("2006-01-02") counts := map[string]int64{mid: 3} series := fillTrendSeries(3, counts) if len(series) != 3 { t.Fatalf("expected 3 points, got %d", len(series)) } var foundMid bool for _, point := range series { if point.Date == mid && point.Count == 3 { foundMid = true } } if !foundMid { t.Fatalf("expected middle day count 3, series=%+v", series) } if series[0].Count != 0 || series[2].Count != 0 { t.Fatalf("expected zero-filled edge days, series=%+v", series) } } func TestNormalizeTrendMetric(t *testing.T) { if got := normalizeTrendMetric("PUBLISHED"); got != "published" { t.Fatalf("expected published, got %q", got) } if got := normalizeTrendMetric(""); got != "created" { t.Fatalf("expected created default, got %q", got) } } func TestListLimitBounds(t *testing.T) { if got := listLimit(0); got != defaultListLimit { t.Fatalf("expected default %d, got %d", defaultListLimit, got) } if got := listLimit(99); got != maxListLimit { t.Fatalf("expected max %d, got %d", maxListLimit, got) } }