(t *testing.T)
| 28 | } |
| 29 | |
| 30 | func 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 | |
| 67 | func TestDeclareExchange(t *testing.T) { |
| 68 | var ok bool |
nothing calls this directly
no test coverage detected