(t *testing.T)
| 1623 | } |
| 1624 | |
| 1625 | func TestHeaderMultiLine(t *testing.T) { |
| 1626 | m := NewMsg("foo") |
| 1627 | m.Header = Header{ |
| 1628 | "CorrelationID": []string{"123"}, |
| 1629 | "Msg-ID": []string{"456"}, |
| 1630 | "X-NATS-Keys": []string{"A", "B", "C"}, |
| 1631 | "X-Test-Keys": []string{"D", "E", "F"}, |
| 1632 | } |
| 1633 | // Users can opt-in to canonicalize like http.Header does |
| 1634 | // by using http.Header#Set or http.Header#Add. |
| 1635 | http.Header(m.Header).Set("accept-encoding", "json") |
| 1636 | http.Header(m.Header).Add("AUTHORIZATION", "s3cr3t") |
| 1637 | |
| 1638 | // Multi Value Header becomes represented as multi-lines in the wire |
| 1639 | // since internally using same Write from http stdlib. |
| 1640 | m.Header.Set("X-Test", "First") |
| 1641 | m.Header.Add("X-Test", "Second") |
| 1642 | m.Header.Add("X-Test", "Third") |
| 1643 | |
| 1644 | b, err := m.headerBytes() |
| 1645 | if err != nil { |
| 1646 | t.Fatal(err) |
| 1647 | } |
| 1648 | result := string(b) |
| 1649 | |
| 1650 | expectedHeader := `NATS/1.0 |
| 1651 | Accept-Encoding: json |
| 1652 | Authorization: s3cr3t |
| 1653 | CorrelationID: 123 |
| 1654 | Msg-ID: 456 |
| 1655 | X-NATS-Keys: A |
| 1656 | X-NATS-Keys: B |
| 1657 | X-NATS-Keys: C |
| 1658 | X-Test: First |
| 1659 | X-Test: Second |
| 1660 | X-Test: Third |
| 1661 | X-Test-Keys: D |
| 1662 | X-Test-Keys: E |
| 1663 | X-Test-Keys: F |
| 1664 | |
| 1665 | ` |
| 1666 | if strings.Replace(expectedHeader, "\n", "\r\n", -1) != result { |
| 1667 | t.Fatalf("Expected: %q, got: %q", expectedHeader, result) |
| 1668 | } |
| 1669 | } |
| 1670 | |
| 1671 | func TestLameDuckMode(t *testing.T) { |
| 1672 | l, err := net.Listen("tcp", "127.0.0.1:0") |
nothing calls this directly
no test coverage detected