(t *testing.T)
| 554 | } |
| 555 | |
| 556 | func TestConnectedAddr(t *testing.T) { |
| 557 | s := RunServerOnPort(TEST_PORT) |
| 558 | defer s.Shutdown() |
| 559 | |
| 560 | var nc *nats.Conn |
| 561 | if addr := nc.ConnectedAddr(); addr != "" { |
| 562 | t.Fatalf("Expected empty result for nil connection, got %q", addr) |
| 563 | } |
| 564 | nc, err := nats.Connect(fmt.Sprintf("localhost:%d", TEST_PORT)) |
| 565 | if err != nil { |
| 566 | t.Fatalf("Error connecting: %v", err) |
| 567 | } |
| 568 | expected := s.Addr().String() |
| 569 | if addr := nc.ConnectedAddr(); addr != expected { |
| 570 | t.Fatalf("Expected address %q, got %q", expected, addr) |
| 571 | } |
| 572 | nc.Close() |
| 573 | if addr := nc.ConnectedAddr(); addr != "" { |
| 574 | t.Fatalf("Expected empty result for closed connection, got %q", addr) |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | func TestLocalAddr(t *testing.T) { |
| 579 | s := RunServerOnPort(TEST_PORT) |
nothing calls this directly
no test coverage detected