优化定时抢购界面

This commit is contained in:
yml2213
2026-07-06 22:30:48 +08:00
parent ce6fdcc371
commit 327b996079
4 changed files with 325 additions and 72 deletions
+34 -1
View File
@@ -1,6 +1,9 @@
package gui
import "testing"
import (
"testing"
"time"
)
func TestSplitCookieLinesNormalizesLineBreaks(t *testing.T) {
tests := []struct {
@@ -44,3 +47,33 @@ func TestSplitCookieLinesNormalizesLineBreaks(t *testing.T) {
})
}
}
func TestParseStartTimeAcceptsClockOnly(t *testing.T) {
t.Run("future_today", func(t *testing.T) {
now := time.Date(2026, 7, 6, 10, 20, 30, 0, time.Local)
got := nextClockTime(now, 12, 5, 6)
want := time.Date(2026, 7, 6, 12, 5, 6, 0, time.Local)
if !got.Equal(want) {
t.Fatalf("nextClockTime() = %s, want %s", got, want)
}
})
t.Run("past_tomorrow", func(t *testing.T) {
now := time.Date(2026, 7, 6, 10, 20, 30, 0, time.Local)
got := nextClockTime(now, 9, 5, 6)
want := time.Date(2026, 7, 7, 9, 5, 6, 0, time.Local)
if !got.Equal(want) {
t.Fatalf("nextClockTime() = %s, want %s", got, want)
}
})
t.Run("parse_hms", func(t *testing.T) {
got, err := parseStartTime("23:59:58")
if err != nil {
t.Fatalf("parseStartTime() error = %v", err)
}
if got.Hour() != 23 || got.Minute() != 59 || got.Second() != 58 {
t.Fatalf("parseStartTime() = %s, want 23:59:58", got)
}
})
}