Release v1.4.7 with unlimited default timeout

This commit is contained in:
lutc5
2026-05-06 16:29:35 +08:00
parent fe1d5b5348
commit 22f793c188
13 changed files with 73 additions and 25 deletions

View File

@@ -1,8 +1,10 @@
package service
import (
"context"
"errors"
"testing"
"time"
)
func TestIsRecoverableIPCError(t *testing.T) {
@@ -23,3 +25,26 @@ func TestIsRecoverableIPCErrorIgnoresModelErrors(t *testing.T) {
t.Fatal("timeout should not be treated as an immediate reconnect retry")
}
}
func TestNewKeepsZeroTimeoutUnlimited(t *testing.T) {
svc := New(Config{Timeout: 0})
if svc.cfg.Timeout != 0 {
t.Fatalf("timeout = %v, want 0", svc.cfg.Timeout)
}
}
func TestContextWithOptionalTimeoutZeroDoesNotSetDeadline(t *testing.T) {
ctx, cancel := contextWithOptionalTimeout(context.Background(), 0)
defer cancel()
if _, ok := ctx.Deadline(); ok {
t.Fatal("zero timeout should not set a deadline")
}
}
func TestContextWithOptionalTimeoutPositiveSetsDeadline(t *testing.T) {
ctx, cancel := contextWithOptionalTimeout(context.Background(), time.Second)
defer cancel()
if _, ok := ctx.Deadline(); !ok {
t.Fatal("positive timeout should set a deadline")
}
}