-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpublisher_test.go
49 lines (42 loc) · 1.14 KB
/
publisher_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package rabbit_test
import (
"testing"
"github.com/brettallred/go-rabbit"
"github.com/stretchr/testify/assert"
)
func TestPublish(t *testing.T) {
var subscriber = rabbit.Subscriber{
Concurrency: 5,
Durable: true,
Exchange: "events_test",
Queue: "test.publishsample.event.created",
RoutingKey: "publishsample.event.created",
}
assert := assert.New(t)
recreateQueue(t, &subscriber)
message := "Test Message"
publisher := rabbit.NewPublisher(make(chan bool))
publisher.Publish(message, &subscriber)
var result string
result, _ = rabbit.Pop(&subscriber)
assert.Equal(message, result)
}
func TestConfirm(t *testing.T) {
var subscriber = rabbit.Subscriber{
Concurrency: 5,
Durable: true,
Exchange: "events_test",
Queue: "test.confirmsample.event.created",
RoutingKey: "confirmsample.event.created",
}
publisher := rabbit.NewPublisher(make(chan bool))
confirms := publisher.NotifyPublish(1)
publisher.Confirm(false)
publisher.Publish("something", &subscriber)
rabbit.Pop(&subscriber)
<-confirms
publisher.Close()
publisher.Publish("something", &subscriber)
rabbit.Pop(&subscriber)
<-confirms
}