mirror of
https://github.com/MengMengCode/VoCat.git
synced 2026-08-13 03:13:43 +08:00
- 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.
31 lines
886 B
Go
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")
|
|
}
|
|
}
|