@@ -105,7 +105,7 @@ func Test_updateHandler(t *testing.T) {
105
105
So (received , ShouldBeTrue )
106
106
})
107
107
108
- Convey ("enqueus all updates if no Subscriptions are provided" , func () {
108
+ Convey ("enqueues all updates if no Subscriptions are provided" , func () {
109
109
evtState := deepcopy .Copy (state ).(* catalog.ServicesState )
110
110
evtState .LastChanged = time .Now ().UTC ()
111
111
@@ -223,5 +223,33 @@ func Test_updateHandler(t *testing.T) {
223
223
So (lastReceivedState .LastChanged .Before (state .LastChanged ), ShouldBeTrue )
224
224
So (len (lastReceivedState .Servers ["chaucer" ].Services ), ShouldEqual , 2 )
225
225
})
226
+
227
+ Convey ("enqueues an update to mark a service as DRAINING" , func () {
228
+ evtState := deepcopy .Copy (state ).(* catalog.ServicesState )
229
+ evtState .LastChanged = time .Now ().UTC ()
230
+
231
+ change := catalog.StateChangedEvent {
232
+ State : evtState ,
233
+ ChangeEvent : catalog.ChangeEvent {
234
+ Service : service.Service {
235
+ Name : "nobody-wants-this" ,
236
+ ID : "10101010101" ,
237
+ Updated : time .Now ().UTC (),
238
+ Created : time .Now ().UTC (),
239
+ Status : service .DRAINING ,
240
+ },
241
+ PreviousStatus : service .ALIVE ,
242
+ },
243
+ }
244
+
245
+ encoded , _ := json .Marshal (change )
246
+ req := httptest .NewRequest ("POST" , "/update" , bytes .NewBuffer (encoded ))
247
+
248
+ UpdateHandler (recorder , req , rcvr )
249
+ resp := recorder .Result ()
250
+
251
+ So (resp .StatusCode , ShouldEqual , 200 )
252
+ So (len (rcvr .ReloadChan ), ShouldEqual , 1 )
253
+ })
226
254
})
227
255
}
0 commit comments