Files
VoCat/internal/server/automatic_tasks_test.go
T
MengMengCode 8a260e86f1 Implement automatic task management with CRUD operations and UI integration
- Added `automatic_tasks.go` and `automatic_tasks_test.go` for backend logic and testing of automatic tasks.
- Created `automatic_tasks_test.go` to validate task claiming and deletion behavior.
- Developed `AutomaticTasksPage.tsx` for frontend management of automatic tasks, including task creation, editing, and execution.
- Integrated device and eSIM profile selection for task configuration.
- Implemented automatic task scheduling and retry logic in the backend.
2026-08-10 22:15:54 +08:00

31 lines
886 B
Go

package server
import (
"testing"
"time"
)
func TestNextAutomaticRunUsesIntervalAndLocalClock(t *testing.T) {
location := time.FixedZone("test", 8*60*60)
now := time.Date(2026, 8, 10, 12, 0, 0, 0, location)
next, err := nextAutomaticRun("2026-08-01", "09:30", 3, now)
if err != nil {
t.Fatal(err)
}
want := time.Date(2026, 8, 13, 9, 30, 0, 0, location)
if !next.Equal(want) {
t.Fatalf("next run = %v, want %v", next, want)
}
}
func TestAutomaticSMSRetrySafetyPreventsDuplicateSubmission(t *testing.T) {
unsafe := []byte(`{"data":{"parts_attempted":1,"parts_accepted":1,"retry_safe":false}}`)
if automaticSMSRetrySafe(unsafe) {
t.Fatal("partially submitted SMS was considered safe to retry")
}
safe := []byte(`{"data":{"parts_attempted":0,"parts_accepted":0}}`)
if !automaticSMSRetrySafe(safe) {
t.Fatal("unattempted SMS was not considered safe to retry")
}
}