(t *testing.T)
| 737 | } |
| 738 | |
| 739 | func TestConnCloseNoCallback(t *testing.T) { |
| 740 | ts := startReconnectServer(t) |
| 741 | defer ts.Shutdown() |
| 742 | |
| 743 | // create a connection that manually sets the options |
| 744 | var conns []*nats.Conn |
| 745 | cch := make(chan string, 2) |
| 746 | opts := reconnectOpts |
| 747 | opts.ClosedCB = func(_ *nats.Conn) { |
| 748 | cch <- "manual" |
| 749 | } |
| 750 | opts.NoCallbacksAfterClientClose = true |
| 751 | nc, err := opts.Connect() |
| 752 | if err != nil { |
| 753 | t.Fatalf("Should have connected ok: %v", err) |
| 754 | } |
| 755 | conns = append(conns, nc) |
| 756 | |
| 757 | // and another connection that uses the option |
| 758 | nc2, err := nats.Connect(reconnectOpts.Url, nats.NoCallbacksAfterClientClose(), |
| 759 | nats.ClosedHandler(func(_ *nats.Conn) { |
| 760 | cch <- "opts" |
| 761 | })) |
| 762 | if err != nil { |
| 763 | t.Fatalf("Should have connected ok: %v", err) |
| 764 | } |
| 765 | conns = append(conns, nc2) |
| 766 | |
| 767 | // defer close() for safety, flush() and close() |
| 768 | for _, c := range conns { |
| 769 | defer c.Close() |
| 770 | c.Flush() |
| 771 | |
| 772 | // Close the connection, we don't expect to get a notification |
| 773 | c.Close() |
| 774 | } |
| 775 | |
| 776 | // if the timeout happens we didn't get data from the channel |
| 777 | // if we get a value from the channel that connection type failed. |
| 778 | select { |
| 779 | case <-time.After(500 * time.Millisecond): |
| 780 | // test passed - we timed so no callback was called |
| 781 | case what := <-cch: |
| 782 | t.Fatalf("%s issued a callback and it shouldn't have", what) |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | func TestReconnectBufSizeDisable(t *testing.T) { |
| 787 | s := RunDefaultServer() |
nothing calls this directly
no test coverage detected