(t *testing.T)
| 674 | } |
| 675 | |
| 676 | func TestContextBadSubscription(t *testing.T) { |
| 677 | s := RunDefaultServer() |
| 678 | defer s.Shutdown() |
| 679 | |
| 680 | nc := NewDefaultConnection(t) |
| 681 | defer nc.Close() |
| 682 | ctx, cancelCB := context.WithCancel(context.Background()) |
| 683 | defer cancelCB() |
| 684 | time.AfterFunc(100*time.Millisecond, func() { |
| 685 | cancelCB() |
| 686 | }) |
| 687 | |
| 688 | sub, err := nc.Subscribe("foo", func(_ *nats.Msg) {}) |
| 689 | if err != nil { |
| 690 | t.Fatalf("Expected to be able to subscribe: %s", err) |
| 691 | } |
| 692 | |
| 693 | err = sub.Unsubscribe() |
| 694 | if err != nil { |
| 695 | t.Fatalf("Expected to be able to unsubscribe: %s", err) |
| 696 | } |
| 697 | |
| 698 | _, err = sub.NextMsgWithContext(ctx) |
| 699 | if err == nil { |
| 700 | t.Fatal("Expected to fail getting next message with context") |
| 701 | } |
| 702 | |
| 703 | if err != nats.ErrBadSubscription { |
| 704 | t.Errorf("Expected request to fail with connection closed error: %s", err) |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | func TestFlushWithContext(t *testing.T) { |
| 709 | s := RunDefaultServer() |
nothing calls this directly
no test coverage detected