Merge lp:~pedronis/ubuntu-push/broker-testing into lp:ubuntu-push
- broker-testing
- Merge into trunk
Proposed by
Samuele Pedroni
Status: | Merged |
---|---|
Approved by: | Samuele Pedroni |
Approved revision: | 27 |
Merged at revision: | 22 |
Proposed branch: | lp:~pedronis/ubuntu-push/broker-testing |
Merge into: | lp:ubuntu-push |
Prerequisite: | lp:~pedronis/ubuntu-push/broker-testsuite |
Diff against target: |
634 lines (+166/-132) 11 files modified
server/broker/broker.go (+2/-2) server/broker/broker_test.go (+0/-3) server/broker/exchanges_test.go (+18/-56) server/broker/exchg_impl_test.go (+47/-0) server/broker/simple/simple.go (+1/-1) server/broker/simple/simple_test.go (+7/-14) server/broker/testing/impls.go (+60/-0) server/broker/testsuite/suite.go (+13/-19) server/session/session_test.go (+15/-35) server/session/tracker.go (+1/-1) server/session/tracker_test.go (+2/-1) |
To merge this branch: | bzr merge lp:~pedronis/ubuntu-push/broker-testing |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton (community) | Approve | ||
Review via email:
|
Commit message
introduce reusable TestBrokerConfig and TestBrokerSession
Description of the change
introduce reusable TestBrokerConfig and TestBrokerSession
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'server/broker/broker.go' | |||
2 | --- server/broker/broker.go 2014-01-24 08:01:44 +0000 | |||
3 | +++ server/broker/broker.go 2014-01-24 08:01:44 +0000 | |||
4 | @@ -52,8 +52,8 @@ | |||
5 | 52 | // SessionChannel returns the session control channel | 52 | // SessionChannel returns the session control channel |
6 | 53 | // on which the session gets exchanges to perform. | 53 | // on which the session gets exchanges to perform. |
7 | 54 | SessionChannel() <-chan Exchange | 54 | SessionChannel() <-chan Exchange |
10 | 55 | // DeviceId returns the device id string. | 55 | // DeviceIdentifier returns the device id string. |
11 | 56 | DeviceId() string | 56 | DeviceIdentifier() string |
12 | 57 | // Levels returns the current channel levels for the session | 57 | // Levels returns the current channel levels for the session |
13 | 58 | Levels() LevelsMap | 58 | Levels() LevelsMap |
14 | 59 | // ExchangeScratchArea returns the scratch area for exchanges. | 59 | // ExchangeScratchArea returns the scratch area for exchanges. |
15 | 60 | 60 | ||
16 | === modified file 'server/broker/broker_test.go' | |||
17 | --- server/broker/broker_test.go 2014-01-15 08:39:04 +0000 | |||
18 | +++ server/broker/broker_test.go 2014-01-24 08:01:44 +0000 | |||
19 | @@ -19,11 +19,8 @@ | |||
20 | 19 | import ( | 19 | import ( |
21 | 20 | "fmt" | 20 | "fmt" |
22 | 21 | . "launchpad.net/gocheck" | 21 | . "launchpad.net/gocheck" |
23 | 22 | "testing" | ||
24 | 23 | ) | 22 | ) |
25 | 24 | 23 | ||
26 | 25 | func TestBroker(t *testing.T) { TestingT(t) } | ||
27 | 26 | |||
28 | 27 | type brokerSuite struct{} | 24 | type brokerSuite struct{} |
29 | 28 | 25 | ||
30 | 29 | var _ = Suite(&brokerSuite{}) | 26 | var _ = Suite(&brokerSuite{}) |
31 | 30 | 27 | ||
32 | === modified file 'server/broker/exchanges_test.go' | |||
33 | --- server/broker/exchanges_test.go 2014-01-24 08:01:44 +0000 | |||
34 | +++ server/broker/exchanges_test.go 2014-01-24 08:01:44 +0000 | |||
35 | @@ -14,47 +14,29 @@ | |||
36 | 14 | with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | with this program. If not, see <http://www.gnu.org/licenses/>. |
37 | 15 | */ | 15 | */ |
38 | 16 | 16 | ||
40 | 17 | package broker | 17 | package broker_test // use a package test to avoid cyclic imports |
41 | 18 | 18 | ||
42 | 19 | import ( | 19 | import ( |
43 | 20 | "encoding/json" | 20 | "encoding/json" |
44 | 21 | . "launchpad.net/gocheck" | 21 | . "launchpad.net/gocheck" |
45 | 22 | "launchpad.net/ubuntu-push/server/broker" | ||
46 | 23 | "launchpad.net/ubuntu-push/server/broker/testing" | ||
47 | 22 | "launchpad.net/ubuntu-push/server/store" | 24 | "launchpad.net/ubuntu-push/server/store" |
48 | 23 | // "log" | 25 | // "log" |
49 | 26 | gotesting "testing" | ||
50 | 24 | ) | 27 | ) |
51 | 25 | 28 | ||
52 | 29 | func TestBroker(t *gotesting.T) { TestingT(t) } | ||
53 | 30 | |||
54 | 26 | type exchangesSuite struct{} | 31 | type exchangesSuite struct{} |
55 | 27 | 32 | ||
56 | 28 | var _ = Suite(&exchangesSuite{}) | 33 | var _ = Suite(&exchangesSuite{}) |
57 | 29 | 34 | ||
58 | 30 | type testBrokerSession struct { | ||
59 | 31 | deviceId string | ||
60 | 32 | exchanges chan Exchange | ||
61 | 33 | levels LevelsMap | ||
62 | 34 | exchgScratch ExchangesScratchArea | ||
63 | 35 | } | ||
64 | 36 | |||
65 | 37 | func (tbs *testBrokerSession) SessionChannel() <-chan Exchange { | ||
66 | 38 | return nil | ||
67 | 39 | } | ||
68 | 40 | |||
69 | 41 | func (tbs *testBrokerSession) DeviceId() string { | ||
70 | 42 | return "" | ||
71 | 43 | } | ||
72 | 44 | |||
73 | 45 | func (tbs *testBrokerSession) Levels() LevelsMap { | ||
74 | 46 | return tbs.levels | ||
75 | 47 | } | ||
76 | 48 | |||
77 | 49 | func (tbs *testBrokerSession) ExchangeScratchArea() *ExchangesScratchArea { | ||
78 | 50 | return &tbs.exchgScratch | ||
79 | 51 | } | ||
80 | 52 | |||
81 | 53 | func (s *exchangesSuite) TestBroadcastExchange(c *C) { | 35 | func (s *exchangesSuite) TestBroadcastExchange(c *C) { |
84 | 54 | sess := &testBrokerSession{ | 36 | sess := &testing.TestBrokerSession{ |
85 | 55 | levels: map[store.InternalChannelId]int64{}, | 37 | LevelsMap: broker.LevelsMap(map[store.InternalChannelId]int64{}), |
86 | 56 | } | 38 | } |
88 | 57 | exchg := &BroadcastExchange{ | 39 | exchg := &broker.BroadcastExchange{ |
89 | 58 | ChanId: store.SystemInternalChannelId, | 40 | ChanId: store.SystemInternalChannelId, |
90 | 59 | TopLevel: 3, | 41 | TopLevel: 3, |
91 | 60 | NotificationPayloads: []json.RawMessage{ | 42 | NotificationPayloads: []json.RawMessage{ |
92 | @@ -72,14 +54,14 @@ | |||
93 | 72 | c.Assert(err, IsNil) | 54 | c.Assert(err, IsNil) |
94 | 73 | err = exchg.Acked(sess) | 55 | err = exchg.Acked(sess) |
95 | 74 | c.Assert(err, IsNil) | 56 | c.Assert(err, IsNil) |
97 | 75 | c.Check(sess.levels[store.SystemInternalChannelId], Equals, int64(3)) | 57 | c.Check(sess.LevelsMap[store.SystemInternalChannelId], Equals, int64(3)) |
98 | 76 | } | 58 | } |
99 | 77 | 59 | ||
100 | 78 | func (s *exchangesSuite) TestBroadcastExchangeAckMismatch(c *C) { | 60 | func (s *exchangesSuite) TestBroadcastExchangeAckMismatch(c *C) { |
103 | 79 | sess := &testBrokerSession{ | 61 | sess := &testing.TestBrokerSession{ |
104 | 80 | levels: map[store.InternalChannelId]int64{}, | 62 | LevelsMap: broker.LevelsMap(map[store.InternalChannelId]int64{}), |
105 | 81 | } | 63 | } |
107 | 82 | exchg := &BroadcastExchange{ | 64 | exchg := &broker.BroadcastExchange{ |
108 | 83 | ChanId: store.SystemInternalChannelId, | 65 | ChanId: store.SystemInternalChannelId, |
109 | 84 | TopLevel: 3, | 66 | TopLevel: 3, |
110 | 85 | NotificationPayloads: []json.RawMessage{ | 67 | NotificationPayloads: []json.RawMessage{ |
111 | @@ -96,36 +78,16 @@ | |||
112 | 96 | c.Assert(err, IsNil) | 78 | c.Assert(err, IsNil) |
113 | 97 | err = exchg.Acked(sess) | 79 | err = exchg.Acked(sess) |
114 | 98 | c.Assert(err, Not(IsNil)) | 80 | c.Assert(err, Not(IsNil)) |
136 | 99 | c.Check(sess.levels[store.SystemInternalChannelId], Equals, int64(0)) | 81 | c.Check(sess.LevelsMap[store.SystemInternalChannelId], Equals, int64(0)) |
116 | 100 | } | ||
117 | 101 | |||
118 | 102 | func (s *exchangesSuite) TestFilterByLevel(c *C) { | ||
119 | 103 | payloads := []json.RawMessage{ | ||
120 | 104 | json.RawMessage(`{"a": 3}`), | ||
121 | 105 | json.RawMessage(`{"a": 4}`), | ||
122 | 106 | json.RawMessage(`{"a": 5}`), | ||
123 | 107 | } | ||
124 | 108 | res := filterByLevel(5, 5, payloads) | ||
125 | 109 | c.Check(len(res), Equals, 0) | ||
126 | 110 | res = filterByLevel(4, 5, payloads) | ||
127 | 111 | c.Check(len(res), Equals, 1) | ||
128 | 112 | c.Check(res[0], DeepEquals, json.RawMessage(`{"a": 5}`)) | ||
129 | 113 | res = filterByLevel(3, 5, payloads) | ||
130 | 114 | c.Check(len(res), Equals, 2) | ||
131 | 115 | c.Check(res[0], DeepEquals, json.RawMessage(`{"a": 4}`)) | ||
132 | 116 | res = filterByLevel(2, 5, payloads) | ||
133 | 117 | c.Check(len(res), Equals, 3) | ||
134 | 118 | res = filterByLevel(1, 5, payloads) | ||
135 | 119 | c.Check(len(res), Equals, 3) | ||
137 | 120 | } | 82 | } |
138 | 121 | 83 | ||
139 | 122 | func (s *exchangesSuite) TestBroadcastExchangeFilterByLevel(c *C) { | 84 | func (s *exchangesSuite) TestBroadcastExchangeFilterByLevel(c *C) { |
142 | 123 | sess := &testBrokerSession{ | 85 | sess := &testing.TestBrokerSession{ |
143 | 124 | levels: map[store.InternalChannelId]int64{ | 86 | LevelsMap: broker.LevelsMap(map[store.InternalChannelId]int64{ |
144 | 125 | store.SystemInternalChannelId: 2, | 87 | store.SystemInternalChannelId: 2, |
146 | 126 | }, | 88 | }), |
147 | 127 | } | 89 | } |
149 | 128 | exchg := &BroadcastExchange{ | 90 | exchg := &broker.BroadcastExchange{ |
150 | 129 | ChanId: store.SystemInternalChannelId, | 91 | ChanId: store.SystemInternalChannelId, |
151 | 130 | TopLevel: 3, | 92 | TopLevel: 3, |
152 | 131 | NotificationPayloads: []json.RawMessage{ | 93 | NotificationPayloads: []json.RawMessage{ |
153 | 132 | 94 | ||
154 | === added file 'server/broker/exchg_impl_test.go' | |||
155 | --- server/broker/exchg_impl_test.go 1970-01-01 00:00:00 +0000 | |||
156 | +++ server/broker/exchg_impl_test.go 2014-01-24 08:01:44 +0000 | |||
157 | @@ -0,0 +1,47 @@ | |||
158 | 1 | /* | ||
159 | 2 | Copyright 2013-2014 Canonical Ltd. | ||
160 | 3 | |||
161 | 4 | This program is free software: you can redistribute it and/or modify it | ||
162 | 5 | under the terms of the GNU General Public License version 3, as published | ||
163 | 6 | by the Free Software Foundation. | ||
164 | 7 | |||
165 | 8 | This program is distributed in the hope that it will be useful, but | ||
166 | 9 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
167 | 10 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
168 | 11 | PURPOSE. See the GNU General Public License for more details. | ||
169 | 12 | |||
170 | 13 | You should have received a copy of the GNU General Public License along | ||
171 | 14 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
172 | 15 | */ | ||
173 | 16 | |||
174 | 17 | package broker | ||
175 | 18 | |||
176 | 19 | import ( | ||
177 | 20 | "encoding/json" | ||
178 | 21 | . "launchpad.net/gocheck" | ||
179 | 22 | // "log" | ||
180 | 23 | ) | ||
181 | 24 | |||
182 | 25 | type exchangesImplSuite struct{} | ||
183 | 26 | |||
184 | 27 | var _ = Suite(&exchangesImplSuite{}) | ||
185 | 28 | |||
186 | 29 | func (s *exchangesImplSuite) TestFilterByLevel(c *C) { | ||
187 | 30 | payloads := []json.RawMessage{ | ||
188 | 31 | json.RawMessage(`{"a": 3}`), | ||
189 | 32 | json.RawMessage(`{"a": 4}`), | ||
190 | 33 | json.RawMessage(`{"a": 5}`), | ||
191 | 34 | } | ||
192 | 35 | res := filterByLevel(5, 5, payloads) | ||
193 | 36 | c.Check(len(res), Equals, 0) | ||
194 | 37 | res = filterByLevel(4, 5, payloads) | ||
195 | 38 | c.Check(len(res), Equals, 1) | ||
196 | 39 | c.Check(res[0], DeepEquals, json.RawMessage(`{"a": 5}`)) | ||
197 | 40 | res = filterByLevel(3, 5, payloads) | ||
198 | 41 | c.Check(len(res), Equals, 2) | ||
199 | 42 | c.Check(res[0], DeepEquals, json.RawMessage(`{"a": 4}`)) | ||
200 | 43 | res = filterByLevel(2, 5, payloads) | ||
201 | 44 | c.Check(len(res), Equals, 3) | ||
202 | 45 | res = filterByLevel(1, 5, payloads) | ||
203 | 46 | c.Check(len(res), Equals, 3) | ||
204 | 47 | } | ||
205 | 0 | 48 | ||
206 | === modified file 'server/broker/simple/simple.go' | |||
207 | --- server/broker/simple/simple.go 2014-01-24 08:01:44 +0000 | |||
208 | +++ server/broker/simple/simple.go 2014-01-24 08:01:44 +0000 | |||
209 | @@ -70,7 +70,7 @@ | |||
210 | 70 | return sess.exchanges | 70 | return sess.exchanges |
211 | 71 | } | 71 | } |
212 | 72 | 72 | ||
214 | 73 | func (sess *simpleBrokerSession) DeviceId() string { | 73 | func (sess *simpleBrokerSession) DeviceIdentifier() string { |
215 | 74 | return sess.deviceId | 74 | return sess.deviceId |
216 | 75 | } | 75 | } |
217 | 76 | 76 | ||
218 | 77 | 77 | ||
219 | === modified file 'server/broker/simple/simple_test.go' | |||
220 | --- server/broker/simple/simple_test.go 2014-01-24 08:01:44 +0000 | |||
221 | +++ server/broker/simple/simple_test.go 2014-01-24 08:01:44 +0000 | |||
222 | @@ -20,30 +20,23 @@ | |||
223 | 20 | "encoding/json" | 20 | "encoding/json" |
224 | 21 | . "launchpad.net/gocheck" | 21 | . "launchpad.net/gocheck" |
225 | 22 | "launchpad.net/ubuntu-push/server/broker" | 22 | "launchpad.net/ubuntu-push/server/broker" |
226 | 23 | "launchpad.net/ubuntu-push/server/broker/testing" | ||
227 | 23 | "launchpad.net/ubuntu-push/server/store" | 24 | "launchpad.net/ubuntu-push/server/store" |
228 | 24 | // "log" | 25 | // "log" |
230 | 25 | "testing" | 26 | gotesting "testing" |
231 | 26 | ) | 27 | ) |
232 | 27 | 28 | ||
234 | 28 | func TestSimple(t *testing.T) { TestingT(t) } | 29 | func TestSimple(t *gotesting.T) { TestingT(t) } |
235 | 29 | 30 | ||
236 | 30 | type simpleSuite struct{} | 31 | type simpleSuite struct{} |
237 | 31 | 32 | ||
238 | 32 | var _ = Suite(&simpleSuite{}) | 33 | var _ = Suite(&simpleSuite{}) |
239 | 33 | 34 | ||
249 | 34 | type testBrokerConfig struct{} | 35 | var testBrokerConfig = &testing.TestBrokerConfig{10, 5} |
241 | 35 | |||
242 | 36 | func (tbc *testBrokerConfig) SessionQueueSize() uint { | ||
243 | 37 | return 10 | ||
244 | 38 | } | ||
245 | 39 | |||
246 | 40 | func (tbc *testBrokerConfig) BrokerQueueSize() uint { | ||
247 | 41 | return 5 | ||
248 | 42 | } | ||
250 | 43 | 36 | ||
251 | 44 | func (s *simpleSuite) TestNew(c *C) { | 37 | func (s *simpleSuite) TestNew(c *C) { |
252 | 45 | sto := store.NewInMemoryPendingStore() | 38 | sto := store.NewInMemoryPendingStore() |
254 | 46 | b := NewSimpleBroker(sto, &testBrokerConfig{}, nil) | 39 | b := NewSimpleBroker(sto, testBrokerConfig, nil) |
255 | 47 | c.Check(cap(b.sessionCh), Equals, 5) | 40 | c.Check(cap(b.sessionCh), Equals, 5) |
256 | 48 | c.Check(len(b.registry), Equals, 0) | 41 | c.Check(len(b.registry), Equals, 0) |
257 | 49 | c.Check(b.sto, Equals, sto) | 42 | c.Check(b.sto, Equals, sto) |
258 | @@ -53,7 +46,7 @@ | |||
259 | 53 | sto := store.NewInMemoryPendingStore() | 46 | sto := store.NewInMemoryPendingStore() |
260 | 54 | notification1 := json.RawMessage(`{"m": "M"}`) | 47 | notification1 := json.RawMessage(`{"m": "M"}`) |
261 | 55 | sto.AppendToChannel(store.SystemInternalChannelId, notification1) | 48 | sto.AppendToChannel(store.SystemInternalChannelId, notification1) |
263 | 56 | b := NewSimpleBroker(sto, &testBrokerConfig{}, nil) | 49 | b := NewSimpleBroker(sto, testBrokerConfig, nil) |
264 | 57 | sess := &simpleBrokerSession{ | 50 | sess := &simpleBrokerSession{ |
265 | 58 | exchanges: make(chan broker.Exchange, 1), | 51 | exchanges: make(chan broker.Exchange, 1), |
266 | 59 | } | 52 | } |
267 | @@ -71,7 +64,7 @@ | |||
268 | 71 | sto := store.NewInMemoryPendingStore() | 64 | sto := store.NewInMemoryPendingStore() |
269 | 72 | notification1 := json.RawMessage(`{"m": "M"}`) | 65 | notification1 := json.RawMessage(`{"m": "M"}`) |
270 | 73 | sto.AppendToChannel(store.SystemInternalChannelId, notification1) | 66 | sto.AppendToChannel(store.SystemInternalChannelId, notification1) |
272 | 74 | b := NewSimpleBroker(sto, &testBrokerConfig{}, nil) | 67 | b := NewSimpleBroker(sto, testBrokerConfig, nil) |
273 | 75 | sess := &simpleBrokerSession{ | 68 | sess := &simpleBrokerSession{ |
274 | 76 | exchanges: make(chan broker.Exchange, 1), | 69 | exchanges: make(chan broker.Exchange, 1), |
275 | 77 | levels: map[store.InternalChannelId]int64{ | 70 | levels: map[store.InternalChannelId]int64{ |
276 | 78 | 71 | ||
277 | === added directory 'server/broker/testing' | |||
278 | === added file 'server/broker/testing/impls.go' | |||
279 | --- server/broker/testing/impls.go 1970-01-01 00:00:00 +0000 | |||
280 | +++ server/broker/testing/impls.go 2014-01-24 08:01:44 +0000 | |||
281 | @@ -0,0 +1,60 @@ | |||
282 | 1 | /* | ||
283 | 2 | Copyright 2013-2014 Canonical Ltd. | ||
284 | 3 | |||
285 | 4 | This program is free software: you can redistribute it and/or modify it | ||
286 | 5 | under the terms of the GNU General Public License version 3, as published | ||
287 | 6 | by the Free Software Foundation. | ||
288 | 7 | |||
289 | 8 | This program is distributed in the hope that it will be useful, but | ||
290 | 9 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
291 | 10 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
292 | 11 | PURPOSE. See the GNU General Public License for more details. | ||
293 | 12 | |||
294 | 13 | You should have received a copy of the GNU General Public License along | ||
295 | 14 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
296 | 15 | */ | ||
297 | 16 | |||
298 | 17 | // Package testing contains simple test implementations of some broker interfaces. | ||
299 | 18 | package testing | ||
300 | 19 | |||
301 | 20 | import ( | ||
302 | 21 | "launchpad.net/ubuntu-push/server/broker" | ||
303 | 22 | ) | ||
304 | 23 | |||
305 | 24 | // Test implementation of BrokerSession. | ||
306 | 25 | type TestBrokerSession struct { | ||
307 | 26 | DeviceId string | ||
308 | 27 | Exchanges chan broker.Exchange | ||
309 | 28 | LevelsMap broker.LevelsMap | ||
310 | 29 | exchgScratch broker.ExchangesScratchArea | ||
311 | 30 | } | ||
312 | 31 | |||
313 | 32 | func (tbs *TestBrokerSession) DeviceIdentifier() string { | ||
314 | 33 | return tbs.DeviceId | ||
315 | 34 | } | ||
316 | 35 | |||
317 | 36 | func (tbs *TestBrokerSession) SessionChannel() <-chan broker.Exchange { | ||
318 | 37 | return tbs.Exchanges | ||
319 | 38 | } | ||
320 | 39 | |||
321 | 40 | func (tbs *TestBrokerSession) Levels() broker.LevelsMap { | ||
322 | 41 | return tbs.LevelsMap | ||
323 | 42 | } | ||
324 | 43 | |||
325 | 44 | func (tbs *TestBrokerSession) ExchangeScratchArea() *broker.ExchangesScratchArea { | ||
326 | 45 | return &tbs.exchgScratch | ||
327 | 46 | } | ||
328 | 47 | |||
329 | 48 | // Test implementation of BrokerConfig. | ||
330 | 49 | type TestBrokerConfig struct { | ||
331 | 50 | ConfigSessionQueueSize uint | ||
332 | 51 | ConfigBrokerQueueSize uint | ||
333 | 52 | } | ||
334 | 53 | |||
335 | 54 | func (tbc *TestBrokerConfig) SessionQueueSize() uint { | ||
336 | 55 | return tbc.ConfigSessionQueueSize | ||
337 | 56 | } | ||
338 | 57 | |||
339 | 58 | func (tbc *TestBrokerConfig) BrokerQueueSize() uint { | ||
340 | 59 | return tbc.ConfigBrokerQueueSize | ||
341 | 60 | } | ||
342 | 0 | 61 | ||
343 | === modified file 'server/broker/testsuite/suite.go' | |||
344 | --- server/broker/testsuite/suite.go 2014-01-24 08:01:44 +0000 | |||
345 | +++ server/broker/testsuite/suite.go 2014-01-24 08:01:44 +0000 | |||
346 | @@ -24,6 +24,7 @@ | |||
347 | 24 | "launchpad.net/ubuntu-push/logger" | 24 | "launchpad.net/ubuntu-push/logger" |
348 | 25 | "launchpad.net/ubuntu-push/protocol" | 25 | "launchpad.net/ubuntu-push/protocol" |
349 | 26 | "launchpad.net/ubuntu-push/server/broker" | 26 | "launchpad.net/ubuntu-push/server/broker" |
350 | 27 | "launchpad.net/ubuntu-push/server/broker/testing" | ||
351 | 27 | "launchpad.net/ubuntu-push/server/store" | 28 | "launchpad.net/ubuntu-push/server/store" |
352 | 28 | helpers "launchpad.net/ubuntu-push/testing" | 29 | helpers "launchpad.net/ubuntu-push/testing" |
353 | 29 | // "log" | 30 | // "log" |
354 | @@ -47,24 +48,16 @@ | |||
355 | 47 | RevealSession func(broker.Broker, string) broker.BrokerSession | 48 | RevealSession func(broker.Broker, string) broker.BrokerSession |
356 | 48 | } | 49 | } |
357 | 49 | 50 | ||
367 | 50 | type testBrokerConfig struct{} | 51 | var testBrokerConfig = &testing.TestBrokerConfig{10, 5} |
359 | 51 | |||
360 | 52 | func (tbc *testBrokerConfig) SessionQueueSize() uint { | ||
361 | 53 | return 10 | ||
362 | 54 | } | ||
363 | 55 | |||
364 | 56 | func (tbc *testBrokerConfig) BrokerQueueSize() uint { | ||
365 | 57 | return 5 | ||
366 | 58 | } | ||
368 | 59 | 52 | ||
369 | 60 | func (s *CommonBrokerSuite) TestSanity(c *C) { | 53 | func (s *CommonBrokerSuite) TestSanity(c *C) { |
370 | 61 | sto := store.NewInMemoryPendingStore() | 54 | sto := store.NewInMemoryPendingStore() |
372 | 62 | b := s.MakeBroker(sto, &testBrokerConfig{}, nil) | 55 | b := s.MakeBroker(sto, testBrokerConfig, nil) |
373 | 63 | c.Check(s.RevealSession(b, "FOO"), IsNil) | 56 | c.Check(s.RevealSession(b, "FOO"), IsNil) |
374 | 64 | } | 57 | } |
375 | 65 | 58 | ||
376 | 66 | func (s *CommonBrokerSuite) TestStartStop(c *C) { | 59 | func (s *CommonBrokerSuite) TestStartStop(c *C) { |
378 | 67 | b := s.MakeBroker(nil, &testBrokerConfig{}, nil) | 60 | b := s.MakeBroker(nil, testBrokerConfig, nil) |
379 | 68 | b.Start() | 61 | b.Start() |
380 | 69 | c.Check(b.Running(), Equals, true) | 62 | c.Check(b.Running(), Equals, true) |
381 | 70 | b.Start() | 63 | b.Start() |
382 | @@ -75,13 +68,14 @@ | |||
383 | 75 | 68 | ||
384 | 76 | func (s *CommonBrokerSuite) TestRegistration(c *C) { | 69 | func (s *CommonBrokerSuite) TestRegistration(c *C) { |
385 | 77 | sto := store.NewInMemoryPendingStore() | 70 | sto := store.NewInMemoryPendingStore() |
387 | 78 | b := s.MakeBroker(sto, &testBrokerConfig{}, nil) | 71 | b := s.MakeBroker(sto, testBrokerConfig, nil) |
388 | 79 | b.Start() | 72 | b.Start() |
389 | 80 | defer b.Stop() | 73 | defer b.Stop() |
390 | 81 | sess, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1", Levels: map[string]int64{"0": 5}}) | 74 | sess, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1", Levels: map[string]int64{"0": 5}}) |
391 | 82 | c.Assert(err, IsNil) | 75 | c.Assert(err, IsNil) |
392 | 83 | c.Assert(s.RevealSession(b, "dev-1"), Equals, sess) | 76 | c.Assert(s.RevealSession(b, "dev-1"), Equals, sess) |
394 | 84 | c.Assert(sess.DeviceId(), Equals, "dev-1") | 77 | c.Assert(sess.DeviceIdentifier(), Equals, "dev-1") |
395 | 78 | c.Assert(sess.ExchangeScratchArea(), Not(IsNil)) | ||
396 | 85 | c.Check(sess.Levels(), DeepEquals, broker.LevelsMap(map[store.InternalChannelId]int64{ | 79 | c.Check(sess.Levels(), DeepEquals, broker.LevelsMap(map[store.InternalChannelId]int64{ |
397 | 86 | store.SystemInternalChannelId: 5, | 80 | store.SystemInternalChannelId: 5, |
398 | 87 | })) | 81 | })) |
399 | @@ -94,7 +88,7 @@ | |||
400 | 94 | 88 | ||
401 | 95 | func (s *CommonBrokerSuite) TestRegistrationBrokenLevels(c *C) { | 89 | func (s *CommonBrokerSuite) TestRegistrationBrokenLevels(c *C) { |
402 | 96 | sto := store.NewInMemoryPendingStore() | 90 | sto := store.NewInMemoryPendingStore() |
404 | 97 | b := s.MakeBroker(sto, &testBrokerConfig{}, nil) | 91 | b := s.MakeBroker(sto, testBrokerConfig, nil) |
405 | 98 | b.Start() | 92 | b.Start() |
406 | 99 | defer b.Stop() | 93 | defer b.Stop() |
407 | 100 | _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1", Levels: map[string]int64{"z": 5}}) | 94 | _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1", Levels: map[string]int64{"z": 5}}) |
408 | @@ -105,7 +99,7 @@ | |||
409 | 105 | sto := store.NewInMemoryPendingStore() | 99 | sto := store.NewInMemoryPendingStore() |
410 | 106 | notification1 := json.RawMessage(`{"m": "M"}`) | 100 | notification1 := json.RawMessage(`{"m": "M"}`) |
411 | 107 | sto.AppendToChannel(store.SystemInternalChannelId, notification1) | 101 | sto.AppendToChannel(store.SystemInternalChannelId, notification1) |
413 | 108 | b := s.MakeBroker(sto, &testBrokerConfig{}, nil) | 102 | b := s.MakeBroker(sto, testBrokerConfig, nil) |
414 | 109 | b.Start() | 103 | b.Start() |
415 | 110 | defer b.Stop() | 104 | defer b.Stop() |
416 | 111 | sess, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) | 105 | sess, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) |
417 | @@ -117,7 +111,7 @@ | |||
418 | 117 | buf := &helpers.SyncedLogBuffer{} | 111 | buf := &helpers.SyncedLogBuffer{} |
419 | 118 | logger := logger.NewSimpleLogger(buf, "error") | 112 | logger := logger.NewSimpleLogger(buf, "error") |
420 | 119 | sto := &testFailingStore{} | 113 | sto := &testFailingStore{} |
422 | 120 | b := s.MakeBroker(sto, &testBrokerConfig{}, logger) | 114 | b := s.MakeBroker(sto, testBrokerConfig, logger) |
423 | 121 | b.Start() | 115 | b.Start() |
424 | 122 | defer b.Stop() | 116 | defer b.Stop() |
425 | 123 | _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) | 117 | _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) |
426 | @@ -128,7 +122,7 @@ | |||
427 | 128 | 122 | ||
428 | 129 | func (s *CommonBrokerSuite) TestRegistrationLastWins(c *C) { | 123 | func (s *CommonBrokerSuite) TestRegistrationLastWins(c *C) { |
429 | 130 | sto := store.NewInMemoryPendingStore() | 124 | sto := store.NewInMemoryPendingStore() |
431 | 131 | b := s.MakeBroker(sto, &testBrokerConfig{}, nil) | 125 | b := s.MakeBroker(sto, testBrokerConfig, nil) |
432 | 132 | b.Start() | 126 | b.Start() |
433 | 133 | defer b.Stop() | 127 | defer b.Stop() |
434 | 134 | sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) | 128 | sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) |
435 | @@ -146,7 +140,7 @@ | |||
436 | 146 | func (s *CommonBrokerSuite) TestBroadcast(c *C) { | 140 | func (s *CommonBrokerSuite) TestBroadcast(c *C) { |
437 | 147 | sto := store.NewInMemoryPendingStore() | 141 | sto := store.NewInMemoryPendingStore() |
438 | 148 | notification1 := json.RawMessage(`{"m": "M"}`) | 142 | notification1 := json.RawMessage(`{"m": "M"}`) |
440 | 149 | b := s.MakeBroker(sto, &testBrokerConfig{}, nil) | 143 | b := s.MakeBroker(sto, testBrokerConfig, nil) |
441 | 150 | b.Start() | 144 | b.Start() |
442 | 151 | defer b.Stop() | 145 | defer b.Stop() |
443 | 152 | sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) | 146 | sess1, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) |
444 | @@ -195,7 +189,7 @@ | |||
445 | 195 | buf := &helpers.SyncedLogBuffer{Written: make(chan bool, 1)} | 189 | buf := &helpers.SyncedLogBuffer{Written: make(chan bool, 1)} |
446 | 196 | logger := logger.NewSimpleLogger(buf, "error") | 190 | logger := logger.NewSimpleLogger(buf, "error") |
447 | 197 | sto := &testFailingStore{countdownToFail: 1} | 191 | sto := &testFailingStore{countdownToFail: 1} |
449 | 198 | b := s.MakeBroker(sto, &testBrokerConfig{}, logger) | 192 | b := s.MakeBroker(sto, testBrokerConfig, logger) |
450 | 199 | b.Start() | 193 | b.Start() |
451 | 200 | defer b.Stop() | 194 | defer b.Stop() |
452 | 201 | _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) | 195 | _, err := b.Register(&protocol.ConnectMsg{Type: "connect", DeviceId: "dev-1"}) |
453 | 202 | 196 | ||
454 | === modified file 'server/session/session_test.go' | |||
455 | --- server/session/session_test.go 2014-01-24 08:01:44 +0000 | |||
456 | +++ server/session/session_test.go 2014-01-24 08:01:44 +0000 | |||
457 | @@ -28,13 +28,14 @@ | |||
458 | 28 | "launchpad.net/ubuntu-push/logger" | 28 | "launchpad.net/ubuntu-push/logger" |
459 | 29 | "launchpad.net/ubuntu-push/protocol" | 29 | "launchpad.net/ubuntu-push/protocol" |
460 | 30 | "launchpad.net/ubuntu-push/server/broker" | 30 | "launchpad.net/ubuntu-push/server/broker" |
461 | 31 | "launchpad.net/ubuntu-push/server/broker/testing" | ||
462 | 31 | "net" | 32 | "net" |
463 | 32 | "reflect" | 33 | "reflect" |
465 | 33 | "testing" | 34 | gotesting "testing" |
466 | 34 | "time" | 35 | "time" |
467 | 35 | ) | 36 | ) |
468 | 36 | 37 | ||
470 | 37 | func TestSession(t *testing.T) { TestingT(t) } | 38 | func TestSession(t *gotesting.T) { TestingT(t) } |
471 | 38 | 39 | ||
472 | 39 | type sessionSuite struct{} | 40 | type sessionSuite struct{} |
473 | 40 | 41 | ||
474 | @@ -123,34 +124,13 @@ | |||
475 | 123 | return &testBroker{registration: make(chan interface{}, 2)} | 124 | return &testBroker{registration: make(chan interface{}, 2)} |
476 | 124 | } | 125 | } |
477 | 125 | 126 | ||
478 | 126 | type testBrokerSession struct { | ||
479 | 127 | deviceId string | ||
480 | 128 | exchanges chan broker.Exchange | ||
481 | 129 | } | ||
482 | 130 | |||
483 | 131 | func (tbs *testBrokerSession) SessionChannel() <-chan broker.Exchange { | ||
484 | 132 | return tbs.exchanges | ||
485 | 133 | } | ||
486 | 134 | |||
487 | 135 | func (tbs *testBrokerSession) DeviceId() string { | ||
488 | 136 | return tbs.deviceId | ||
489 | 137 | } | ||
490 | 138 | |||
491 | 139 | func (tbs *testBrokerSession) Levels() broker.LevelsMap { | ||
492 | 140 | return nil | ||
493 | 141 | } | ||
494 | 142 | |||
495 | 143 | func (tbs *testBrokerSession) ExchangeScratchArea() *broker.ExchangesScratchArea { | ||
496 | 144 | return nil | ||
497 | 145 | } | ||
498 | 146 | |||
499 | 147 | func (tb *testBroker) Register(connect *protocol.ConnectMsg) (broker.BrokerSession, error) { | 127 | func (tb *testBroker) Register(connect *protocol.ConnectMsg) (broker.BrokerSession, error) { |
500 | 148 | tb.registration <- "register " + connect.DeviceId | 128 | tb.registration <- "register " + connect.DeviceId |
502 | 149 | return &testBrokerSession{connect.DeviceId, nil}, tb.err | 129 | return &testing.TestBrokerSession{DeviceId: connect.DeviceId}, tb.err |
503 | 150 | } | 130 | } |
504 | 151 | 131 | ||
505 | 152 | func (tb *testBroker) Unregister(sess broker.BrokerSession) { | 132 | func (tb *testBroker) Unregister(sess broker.BrokerSession) { |
507 | 153 | tb.registration <- "unregister " + sess.(*testBrokerSession).deviceId | 133 | tb.registration <- "unregister " + sess.DeviceIdentifier() |
508 | 154 | } | 134 | } |
509 | 155 | 135 | ||
510 | 156 | func (s *sessionSuite) TestSessionStart(c *C) { | 136 | func (s *sessionSuite) TestSessionStart(c *C) { |
511 | @@ -176,7 +156,7 @@ | |||
512 | 176 | err := <-errCh | 156 | err := <-errCh |
513 | 177 | c.Check(err, IsNil) | 157 | c.Check(err, IsNil) |
514 | 178 | c.Check(takeNext(brkr.registration), Equals, "register dev-1") | 158 | c.Check(takeNext(brkr.registration), Equals, "register dev-1") |
516 | 179 | c.Check(sess.(*testBrokerSession).deviceId, Equals, "dev-1") | 159 | c.Check(sess.DeviceIdentifier(), Equals, "dev-1") |
517 | 180 | } | 160 | } |
518 | 181 | 161 | ||
519 | 182 | func (s *sessionSuite) TestSessionRegisterError(c *C) { | 162 | func (s *sessionSuite) TestSessionRegisterError(c *C) { |
520 | @@ -242,7 +222,7 @@ | |||
521 | 242 | up := make(chan interface{}, 5) | 222 | up := make(chan interface{}, 5) |
522 | 243 | down := make(chan interface{}, 5) | 223 | down := make(chan interface{}, 5) |
523 | 244 | tp := &testProtocol{up, down} | 224 | tp := &testProtocol{up, down} |
525 | 245 | sess := &testBrokerSession{} | 225 | sess := &testing.TestBrokerSession{} |
526 | 246 | go func() { | 226 | go func() { |
527 | 247 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) | 227 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) |
528 | 248 | }() | 228 | }() |
529 | @@ -263,7 +243,7 @@ | |||
530 | 263 | up := make(chan interface{}, 5) | 243 | up := make(chan interface{}, 5) |
531 | 264 | down := make(chan interface{}, 5) | 244 | down := make(chan interface{}, 5) |
532 | 265 | tp := &testProtocol{up, down} | 245 | tp := &testProtocol{up, down} |
534 | 266 | sess := &testBrokerSession{} | 246 | sess := &testing.TestBrokerSession{} |
535 | 267 | go func() { | 247 | go func() { |
536 | 268 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) | 248 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) |
537 | 269 | }() | 249 | }() |
538 | @@ -279,7 +259,7 @@ | |||
539 | 279 | up := make(chan interface{}, 5) | 259 | up := make(chan interface{}, 5) |
540 | 280 | down := make(chan interface{}, 5) | 260 | down := make(chan interface{}, 5) |
541 | 281 | tp := &testProtocol{up, down} | 261 | tp := &testProtocol{up, down} |
543 | 282 | sess := &testBrokerSession{} | 262 | sess := &testing.TestBrokerSession{} |
544 | 283 | go func() { | 263 | go func() { |
545 | 284 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) | 264 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) |
546 | 285 | }() | 265 | }() |
547 | @@ -332,7 +312,7 @@ | |||
548 | 332 | tp := &testProtocol{up, down} | 312 | tp := &testProtocol{up, down} |
549 | 333 | exchanges := make(chan broker.Exchange, 1) | 313 | exchanges := make(chan broker.Exchange, 1) |
550 | 334 | exchanges <- &testExchange{} | 314 | exchanges <- &testExchange{} |
552 | 335 | sess := &testBrokerSession{exchanges: exchanges} | 315 | sess := &testing.TestBrokerSession{Exchanges: exchanges} |
553 | 336 | go func() { | 316 | go func() { |
554 | 337 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) | 317 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) |
555 | 338 | }() | 318 | }() |
556 | @@ -355,7 +335,7 @@ | |||
557 | 355 | tp := &testProtocol{up, down} | 335 | tp := &testProtocol{up, down} |
558 | 356 | exchanges := make(chan broker.Exchange, 1) | 336 | exchanges := make(chan broker.Exchange, 1) |
559 | 357 | exchanges <- &testExchange{nParts: 2} | 337 | exchanges <- &testExchange{nParts: 2} |
561 | 358 | sess := &testBrokerSession{exchanges: exchanges} | 338 | sess := &testing.TestBrokerSession{Exchanges: exchanges} |
562 | 359 | go func() { | 339 | go func() { |
563 | 360 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) | 340 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) |
564 | 361 | }() | 341 | }() |
565 | @@ -383,7 +363,7 @@ | |||
566 | 383 | exchanges := make(chan broker.Exchange, 1) | 363 | exchanges := make(chan broker.Exchange, 1) |
567 | 384 | prepErr := errors.New("prepare failure") | 364 | prepErr := errors.New("prepare failure") |
568 | 385 | exchanges <- &testExchange{prepErr: prepErr} | 365 | exchanges <- &testExchange{prepErr: prepErr} |
570 | 386 | sess := &testBrokerSession{exchanges: exchanges} | 366 | sess := &testing.TestBrokerSession{Exchanges: exchanges} |
571 | 387 | go func() { | 367 | go func() { |
572 | 388 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) | 368 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) |
573 | 389 | }() | 369 | }() |
574 | @@ -399,7 +379,7 @@ | |||
575 | 399 | exchanges := make(chan broker.Exchange, 1) | 379 | exchanges := make(chan broker.Exchange, 1) |
576 | 400 | finErr := errors.New("finish error") | 380 | finErr := errors.New("finish error") |
577 | 401 | exchanges <- &testExchange{finErr: finErr} | 381 | exchanges <- &testExchange{finErr: finErr} |
579 | 402 | sess := &testBrokerSession{exchanges: exchanges} | 382 | sess := &testing.TestBrokerSession{Exchanges: exchanges} |
580 | 403 | go func() { | 383 | go func() { |
581 | 404 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) | 384 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) |
582 | 405 | }() | 385 | }() |
583 | @@ -418,7 +398,7 @@ | |||
584 | 418 | tp := &testProtocol{up, down} | 398 | tp := &testProtocol{up, down} |
585 | 419 | exchanges := make(chan broker.Exchange, 1) | 399 | exchanges := make(chan broker.Exchange, 1) |
586 | 420 | exchanges <- &testExchange{} | 400 | exchanges <- &testExchange{} |
588 | 421 | sess := &testBrokerSession{exchanges: exchanges} | 401 | sess := &testing.TestBrokerSession{Exchanges: exchanges} |
589 | 422 | go func() { | 402 | go func() { |
590 | 423 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) | 403 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) |
591 | 424 | }() | 404 | }() |
592 | @@ -436,7 +416,7 @@ | |||
593 | 436 | tp := &testProtocol{up, down} | 416 | tp := &testProtocol{up, down} |
594 | 437 | exchanges := make(chan broker.Exchange, 1) | 417 | exchanges := make(chan broker.Exchange, 1) |
595 | 438 | exchanges <- &testExchange{finSleep: 3 * time.Millisecond} | 418 | exchanges <- &testExchange{finSleep: 3 * time.Millisecond} |
597 | 439 | sess := &testBrokerSession{exchanges: exchanges} | 419 | sess := &testing.TestBrokerSession{Exchanges: exchanges} |
598 | 440 | go func() { | 420 | go func() { |
599 | 441 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) | 421 | errCh <- sessionLoop(tp, sess, cfg5msPingInterval2msExchangeTout) |
600 | 442 | }() | 422 | }() |
601 | 443 | 423 | ||
602 | === modified file 'server/session/tracker.go' | |||
603 | --- server/session/tracker.go 2014-01-15 08:55:54 +0000 | |||
604 | +++ server/session/tracker.go 2014-01-24 08:01:44 +0000 | |||
605 | @@ -57,7 +57,7 @@ | |||
606 | 57 | } | 57 | } |
607 | 58 | 58 | ||
608 | 59 | func (trk *tracker) Registered(sess broker.BrokerSession) { | 59 | func (trk *tracker) Registered(sess broker.BrokerSession) { |
610 | 60 | trk.Infof("session(%x) registered %v", trk.sessionId, sess.DeviceId()) | 60 | trk.Infof("session(%x) registered %v", trk.sessionId, sess.DeviceIdentifier()) |
611 | 61 | } | 61 | } |
612 | 62 | 62 | ||
613 | 63 | func (trk *tracker) End(err error) error { | 63 | func (trk *tracker) End(err error) error { |
614 | 64 | 64 | ||
615 | === modified file 'server/session/tracker_test.go' | |||
616 | --- server/session/tracker_test.go 2014-01-15 08:55:54 +0000 | |||
617 | +++ server/session/tracker_test.go 2014-01-24 08:01:44 +0000 | |||
618 | @@ -22,6 +22,7 @@ | |||
619 | 22 | . "launchpad.net/gocheck" | 22 | . "launchpad.net/gocheck" |
620 | 23 | "launchpad.net/ubuntu-push/logger" | 23 | "launchpad.net/ubuntu-push/logger" |
621 | 24 | "launchpad.net/ubuntu-push/server/broker" | 24 | "launchpad.net/ubuntu-push/server/broker" |
622 | 25 | "launchpad.net/ubuntu-push/server/broker/testing" | ||
623 | 25 | "net" | 26 | "net" |
624 | 26 | ) | 27 | ) |
625 | 27 | 28 | ||
626 | @@ -50,7 +51,7 @@ | |||
627 | 50 | logger := logger.NewSimpleLogger(buf, "debug") | 51 | logger := logger.NewSimpleLogger(buf, "debug") |
628 | 51 | track := NewTracker(logger) | 52 | track := NewTracker(logger) |
629 | 52 | track.Start(&testRemoteAddrable{}) | 53 | track.Start(&testRemoteAddrable{}) |
631 | 53 | track.Registered(&testBrokerSession{deviceId: "DEV-ID"}) | 54 | track.Registered(&testing.TestBrokerSession{DeviceId: "DEV-ID"}) |
632 | 54 | regExpected := fmt.Sprintf(`.*connected.*\n.* INFO session\(%x\) registered DEV-ID\n`, track.(*tracker).sessionId) | 55 | regExpected := fmt.Sprintf(`.*connected.*\n.* INFO session\(%x\) registered DEV-ID\n`, track.(*tracker).sessionId) |
633 | 55 | c.Check(buf.String(), Matches, regExpected) | 56 | c.Check(buf.String(), Matches, regExpected) |
634 | 56 | } | 57 | } |
You know me, I like this kind of branch. impls_test. go
Only thing that would've made it sweeter would've been a testing/