package seheweit import ( "testing" "time" ) func TestHistoryWindow(t *testing.T) { now := time.Date(2026, 11, 1, 12, 34, 56, 0, time.UTC) for _, tc := range []struct { hours, wantHours int bucket int64 }{ {-1, 1, 60000}, {0, 1, 60000}, {1, 1, 60000}, {24, 24, 240000}, {168, 168, 1680000}, {999, 168, 1680000}, } { got := Window(tc.hours, now) if got.ToMS != now.UnixMilli() || got.FromMS != now.Add(-time.Duration(tc.wantHours)*time.Hour).UnixMilli() || got.BucketMS != tc.bucket { t.Fatalf("hours=%d %+v", tc.hours, got) } buckets := got.ToMS/got.BucketMS - got.FromMS/got.BucketMS + 1 if buckets > MaxHistoryPoints { t.Fatalf("too many buckets: %d", buckets) } } if RetentionCutoff(now.UnixMilli()) != now.Add(-7*24*time.Hour).UnixMilli() { t.Fatal("retention changed") } if ResourceEventID != "builtin.resource.sample" || ResourceEventType != "resource.sample" { t.Fatal("persisted identifiers changed") } }