Release v1.4.7 with unlimited default timeout
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user