diff --git a/js_test.go b/js_test.go index 2cc51ac8c..9d8412293 100644 --- a/js_test.go +++ b/js_test.go @@ -939,6 +939,7 @@ func TestJetStreamExpiredPullRequests(t *testing.T) { t.Fatalf("Expected error and wait for 250ms, got err=%v and dur=%v", err, dur) } } + } func TestJetStreamSyncSubscribeWithMaxAckPending(t *testing.T) { diff --git a/test/js_test.go b/test/js_test.go index 205a21139..de2efbf1a 100644 --- a/test/js_test.go +++ b/test/js_test.go @@ -6867,6 +6867,22 @@ func testJetStreamFetchContext(t *testing.T, srvs ...*jsServer) { t.Errorf("Expected %d pending messages, got: %d", pending, total) } }) + + t.Run("MaxWait timeout should return nats error", func(t *testing.T) { + _, err := sub.Fetch(1, nats.MaxWait(1*time.Nanosecond)) + if !errors.Is(err, nats.ErrTimeout) { + t.Fatalf("Expect ErrTimeout, got err=%#v", err) + } + }) + + t.Run("Context timeout should return context error", func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond) + defer cancel() + _, err := sub.Fetch(1, nats.Context(ctx)) + if !errors.Is(err, context.DeadlineExceeded) { + t.Fatalf("Expect context.DeadlineExceeded, got err=%#v", err) + } + }) } func TestJetStreamSubscribeContextCancel(t *testing.T) {