(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestContextRequestWithNilConnection(t *testing.T) { |
| 27 | var nc *nats.Conn |
| 28 | |
| 29 | ctx, cancelCB := context.WithTimeout(context.Background(), 100*time.Millisecond) |
| 30 | defer cancelCB() // should always be called, not discarded, to prevent context leak |
| 31 | |
| 32 | _, err := nc.RequestWithContext(ctx, "fast", []byte("")) |
| 33 | if err == nil { |
| 34 | t.Fatal("Expected request with context and nil connection to fail") |
| 35 | } |
| 36 | if err != nats.ErrInvalidConnection { |
| 37 | t.Fatalf("Expected nats.ErrInvalidConnection, got %v\n", err) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func testContextRequestWithTimeout(t *testing.T, nc *nats.Conn) { |
| 42 | nc.Subscribe("slow", func(m *nats.Msg) { |
nothing calls this directly
no test coverage detected