| 56 | } |
| 57 | |
| 58 | func TestBrokerAccessors(t *testing.T) { |
| 59 | broker := NewBroker("abc:123") |
| 60 | |
| 61 | if broker.ID() != -1 { |
| 62 | t.Error("New broker didn't have an ID of -1.") |
| 63 | } |
| 64 | |
| 65 | if broker.Addr() != "abc:123" { |
| 66 | t.Error("New broker didn't have the correct address") |
| 67 | } |
| 68 | |
| 69 | if broker.Rack() != "" { |
| 70 | t.Error("New broker didn't have an unknown rack.") |
| 71 | } |
| 72 | |
| 73 | broker.id = 34 |
| 74 | if broker.ID() != 34 { |
| 75 | t.Error("Manually setting broker ID did not take effect.") |
| 76 | } |
| 77 | |
| 78 | rack := "dc1" |
| 79 | broker.rack = &rack |
| 80 | if broker.Rack() != rack { |
| 81 | t.Error("Manually setting broker rack did not take effect.") |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | type produceResponsePromise struct { |
| 86 | c chan produceResOrError |