-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.go
54 lines (45 loc) · 1011 Bytes
/
client_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
50
51
52
53
54
package msgr
import (
"testing"
tests "github.com/piquette/msgr/testing"
"github.com/stretchr/testify/assert"
)
// Integration tests.
// TestQueueSuccess will smoke test the pub/sub capabilities of the queue client.
func TestQueueSuccess(t *testing.T) {
done := make(chan bool, 1)
testID := "1-1-1"
conf := &Config{
URI: tests.AMQPServiceURL,
Channel: tests.AMQPIntegrationQueue,
}
go func() {
// Consumer.
consumer := ConnectC(conf)
open, messages := consumer.Accept()
assert.True(t, open)
for m := range messages {
e := &tests.QueueEntry{}
err := e.Decode(m.Body)
assert.Nil(t, err)
m.Ack(false)
assert.Equal(t, e.ID, testID)
// Close.
consumer.Close()
}
done <- true
}()
qe := &tests.QueueEntry{
ID: testID,
}
message, err := qe.Encode()
assert.Nil(t, err)
// Outbox.
producer := ConnectP(conf)
success := producer.Post(message)
assert.True(t, success)
// Close.
producer.Close()
<-done
// tests.Delete(tests.AMQPIntegrationQueue)
}