MCPcopy Create free account
hub / github.com/assembla/cony / TestDeclareQueue

Function TestDeclareQueue

declaration_test.go:30–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestDeclareQueue(t *testing.T) {
31 var (
32 callOK, nameOK bool
33 )
34
35 q := &Queue{
36 Name: "Q1",
37 }
38
39 td := &testDeclarer{
40 _QueueDeclare: func(name string) (amqp.Queue, error) {
41 callOK = true
42 if name == "Q1" {
43 nameOK = true
44 }
45 return amqp.Queue{Name: "Q1_REAL"}, nil
46 },
47 }
48
49 testDec := DeclareQueue(q)
50 testDec(td)
51
52 if !callOK {
53 t.Error("DeclareQueue() should call declarer.QueueDeclare()")
54 }
55
56 if q.Name != "Q1_REAL" {
57 t.Error("DeclareQueue() should update queue name from AMQP reply")
58 }
59
60 // call it another time (like reconnect event happened)
61 testDec(td)
62 if !nameOK {
63 t.Error("queue name should be preserved")
64 }
65}
66
67func TestDeclareExchange(t *testing.T) {
68 var ok bool

Callers

nothing calls this directly

Calls 1

DeclareQueueFunction · 0.85

Tested by

no test coverage detected