@@ -201,17 +201,10 @@ func testCloseDelayCollector(t *testing.T, c closeDelayCase) {
201201 })
202202
203203 go mc .Start ()
204-
205- job := & library.Job {
206- Type : library .JobDownload ,
207- Endpoints : []string {"ep" },
208- }
209-
210204 time .Sleep (c .delay )
211205
212- mc .Success (job )
213- job .Type = library .JobUpdate
214- mc .Success (job )
206+ mc .Success (getJob (library .JobDownload ))
207+ mc .Success (getJob (library .JobUpdate ))
215208 mc .Stop (c .immediate )
216209
217210 require .Equal (t , c .expCounter , counter )
@@ -240,20 +233,23 @@ func testFailedSend(t *testing.T, stopImmediate bool) {
240233
241234 go mc .Start ()
242235
243- job := & library.Job {
244- Type : library .JobDownload ,
245- Endpoints : []string {"ep" },
246- }
247-
248- mc .Success (job )
249- job .Type = library .JobUpdate
250- mc .Success (job )
236+ mc .Success (getJob (library .JobDownload ))
237+ mc .Success (getJob (library .JobUpdate ))
251238 mc .Stop (stopImmediate )
252239
253240 // TODO maybe we can stabilize it?
254241 if stopImmediate {
255- require .True (t , mc .successUpdateCount <= 2 , "expected: <= 2, got: %v" , mc .successUpdateCount )
242+ require .LessOrEqual (t , mc .successDownloadCount , uint64 (1 ))
243+ require .LessOrEqual (t , mc .successUpdateCount , uint64 (1 ))
256244 } else {
257- require .Equal (t , uint64 (2 ), mc .successUpdateCount )
245+ require .Equal (t , uint64 (1 ), mc .successDownloadCount )
246+ require .Equal (t , uint64 (1 ), mc .successUpdateCount )
247+ }
248+ }
249+
250+ func getJob (jobType int ) * library.Job {
251+ return & library.Job {
252+ Type : library .JobType (jobType ),
253+ Endpoints : []string {"ep" },
258254 }
259255}
0 commit comments