Files
iotlcm/admin-svr/server/internal/tasks/traffic_usage_monthly_test.go
T

33 lines
992 B
Go

package tasks
import (
"testing"
"time"
)
func TestTrafficUsageMonthlyTaskRegistrations(t *testing.T) {
tests := map[string]string{
"sync_traffic_usage_monthly": "SyncTrafficUsageMonthly",
"start_traffic_usage_full_sync": "StartTrafficUsageFullSync",
}
for name, method := range tests {
if actual := GetInnerTaskName(name); actual != method {
t.Fatalf("task %q registered as %q, want %q", name, actual, method)
}
}
}
func TestTrafficUsageJobLockUsesStableActiveScope(t *testing.T) {
first := time.Date(2026, 9, 20, 23, 59, 0, 0, time.Local)
second := first.Add(2 * time.Minute)
if got := jobLockPeriodKey(first, -1); got != "active" {
t.Fatalf("first active key = %q", got)
}
if got := jobLockPeriodKey(second, -1); got != "active" {
t.Fatalf("second active key = %q", got)
}
if jobLockKey("sync_traffic_usage_daily", first, -1) != jobLockKey("sync_traffic_usage_daily", second, -1) {
t.Fatal("active job lock key must remain stable across midnight")
}
}