(t *testing.T)
| 310 | } |
| 311 | |
| 312 | func TestPublisher_Write(t *testing.T) { |
| 313 | var ok bool |
| 314 | testBuf := []byte("test1") |
| 315 | p := newTestPublisher(PublishingTemplate(amqp.Publishing{AppId: "app1"})) |
| 316 | testErr := errors.New("testing error") |
| 317 | |
| 318 | go func() { |
| 319 | envelop := <-p.pubChan |
| 320 | msg := <-envelop.pub |
| 321 | if bytes.Compare(msg.Body, testBuf) == 0 { |
| 322 | if msg.AppId == "app1" { |
| 323 | ok = true |
| 324 | } |
| 325 | } |
| 326 | envelop.err <- testErr |
| 327 | }() |
| 328 | |
| 329 | n, err := p.Write(testBuf) |
| 330 | |
| 331 | if n != len(testBuf) { |
| 332 | t.Error("Write() should return len equal to input buffer") |
| 333 | } |
| 334 | |
| 335 | if err != testErr { |
| 336 | t.Error("Write() should return correct error") |
| 337 | } |
| 338 | |
| 339 | if !ok { |
| 340 | t.Error("Write() send incorrect message") |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | func TestPublishingTemplate(t *testing.T) { |
| 345 | p := newTestPublisher() |
nothing calls this directly
no test coverage detected