package jobs import ( "testing" "time" "warpbox.dev/backend/libs/services" ) func TestShouldDeleteBox(t *testing.T) { now := time.Date(2026, 5, 29, 12, 0, 0, 0, time.UTC) tests := map[string]struct { box services.Box want bool }{ "expired": { box: services.Box{ExpiresAt: now.Add(-time.Second)}, want: true, }, "expires now": { box: services.Box{ExpiresAt: now}, want: true, }, "download limit reached": { box: services.Box{ExpiresAt: now.Add(time.Hour), MaxDownloads: 3, DownloadCount: 3}, want: true, }, "download limit exceeded": { box: services.Box{ExpiresAt: now.Add(time.Hour), MaxDownloads: 3, DownloadCount: 4}, want: true, }, "active unlimited": { box: services.Box{ExpiresAt: now.Add(time.Hour)}, want: false, }, "active under limit": { box: services.Box{ExpiresAt: now.Add(time.Hour), MaxDownloads: 3, DownloadCount: 2}, want: false, }, } for name, tt := range tests { t.Run(name, func(t *testing.T) { if got := shouldDeleteBox(tt.box, now); got != tt.want { t.Fatalf("shouldDeleteBox() = %v, want %v", got, tt.want) } }) } }