fix: parse configured dispatch delay strings

This commit is contained in:
richjohnrambo
2026-10-13 17:05:53 +08:00
parent acbfaf97a6
commit 7eedbde4ab
2 changed files with 27 additions and 0 deletions
+22
View File
@@ -2,6 +2,28 @@ package store
import "testing"
func TestJSONInt(t *testing.T) {
tests := []struct {
name string
value any
want int
ok bool
}{
{name: "number", value: float64(900), want: 900, ok: true},
{name: "numeric string", value: "1200", want: 1200, ok: true},
{name: "trimmed numeric string", value: " 900 ", want: 900, ok: true},
{name: "invalid string", value: "15 minutes", ok: false},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got, ok := jsonInt(test.value)
if got != test.want || ok != test.ok {
t.Fatalf("jsonInt(%v) = (%d, %v), want (%d, %v)", test.value, got, ok, test.want, test.ok)
}
})
}
}
func TestRandomDelaySeconds(t *testing.T) {
for index := 0; index < 100; index++ {
value := randomDelaySeconds(900, 1200)