(t *testing.T)
| 108 | func (*driverSub) Close() error { return nil } |
| 109 | |
| 110 | func TestSendReceive(t *testing.T) { |
| 111 | ctx := context.Background() |
| 112 | ds := NewDriverSub() |
| 113 | dt := &driverTopic{ |
| 114 | subs: []*driverSub{ds}, |
| 115 | } |
| 116 | topic := NewTopic(dt, nil) |
| 117 | defer topic.Shutdown(ctx) |
| 118 | m := &Message{LoggableID: "foo", Body: []byte("user signed up")} |
| 119 | if err := topic.Send(ctx, m); err == nil { |
| 120 | t.Fatalf("expected a Send with a non-empty LoggableID to fail") |
| 121 | } |
| 122 | m.LoggableID = "" |
| 123 | if err := topic.Send(ctx, m); err != nil { |
| 124 | t.Fatal(err) |
| 125 | } |
| 126 | |
| 127 | sub := NewSubscription(ds, nil, nil) |
| 128 | defer sub.Shutdown(ctx) |
| 129 | m2, err := sub.Receive(ctx) |
| 130 | if err != nil { |
| 131 | t.Fatal(err) |
| 132 | } |
| 133 | if string(m2.Body) != string(m.Body) { |
| 134 | t.Fatalf("received message has body %q, want %q", m2.Body, m.Body) |
| 135 | } |
| 136 | m2.Ack() |
| 137 | } |
| 138 | |
| 139 | func TestConcurrentReceivesGetAllTheMessages(t *testing.T) { |
| 140 | howManyToSend := int(1e3) |
nothing calls this directly
no test coverage detected