(t *testing.T)
| 31 | ) |
| 32 | |
| 33 | func TestBasicHeaders(t *testing.T) { |
| 34 | s := RunServerOnPort(-1) |
| 35 | defer s.Shutdown() |
| 36 | |
| 37 | nc, err := nats.Connect(s.ClientURL()) |
| 38 | if err != nil { |
| 39 | t.Fatalf("Error connecting to server: %v", err) |
| 40 | } |
| 41 | defer nc.Close() |
| 42 | |
| 43 | subject := "headers.test" |
| 44 | sub, err := nc.SubscribeSync(subject) |
| 45 | if err != nil { |
| 46 | t.Fatalf("Could not subscribe to %q: %v", subject, err) |
| 47 | } |
| 48 | defer sub.Unsubscribe() |
| 49 | |
| 50 | m := nats.NewMsg(subject) |
| 51 | m.Header.Add("Accept-Encoding", "json") |
| 52 | m.Header.Add("Authorization", "s3cr3t") |
| 53 | m.Data = []byte("Hello Headers!") |
| 54 | |
| 55 | nc.PublishMsg(m) |
| 56 | msg, err := sub.NextMsg(time.Second) |
| 57 | if err != nil { |
| 58 | t.Fatalf("Did not receive response: %v", err) |
| 59 | } |
| 60 | |
| 61 | if !m.Equal(msg) { |
| 62 | t.Fatalf("Messages did not match! \n%+v\n%+v\n", m, msg) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | func TestRequestMsg(t *testing.T) { |
| 67 | s := RunServerOnPort(-1) |
nothing calls this directly
no test coverage detected