(t *testing.T)
| 576 | } |
| 577 | |
| 578 | func TestLocalAddr(t *testing.T) { |
| 579 | s := RunServerOnPort(TEST_PORT) |
| 580 | defer s.Shutdown() |
| 581 | |
| 582 | var nc *nats.Conn |
| 583 | if addr := nc.LocalAddr(); addr != "" { |
| 584 | t.Fatalf("Expected empty result for nil connection, got %q", addr) |
| 585 | } |
| 586 | nc, err := nats.Connect(fmt.Sprintf("localhost:%d", TEST_PORT)) |
| 587 | if err != nil { |
| 588 | t.Fatalf("Error connecting: %v", err) |
| 589 | } |
| 590 | addr := nc.LocalAddr() |
| 591 | if addr == "" { |
| 592 | t.Fatalf("Expected non-empty local address") |
| 593 | } |
| 594 | // Verify it's a valid address format |
| 595 | host, port, err := net.SplitHostPort(addr) |
| 596 | if err != nil { |
| 597 | t.Fatalf("Expected valid host:port format, got %q: %v", addr, err) |
| 598 | } |
| 599 | if host == "" { |
| 600 | t.Fatalf("Expected non-empty host in address %q", addr) |
| 601 | } |
| 602 | if port == "" { |
| 603 | t.Fatalf("Expected non-empty port in address %q", addr) |
| 604 | } |
| 605 | nc.Close() |
| 606 | if addr := nc.LocalAddr(); addr != "" { |
| 607 | t.Fatalf("Expected empty result for closed connection, got %q", addr) |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | func TestSubscribeSyncRace(t *testing.T) { |
| 612 | s := RunServerOnPort(TEST_PORT) |
nothing calls this directly
no test coverage detected