优化定时抢购界面
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user