@@ -206,42 +206,34 @@ func Test_loopConditionUntilContext_semantic(t *testing.T) {
206
206
}
207
207
208
208
for _ , test := range tests {
209
- for _ , immediate := range []bool {true , false } {
210
- t .Run (fmt .Sprintf ("immediate=%t" , immediate ), func (t * testing.T ) {
211
- for _ , sliding := range []bool {true , false } {
212
- t .Run (fmt .Sprintf ("sliding=%t" , sliding ), func (t * testing.T ) {
213
- t .Run (test .name , func (t * testing.T ) {
214
- contextFn := test .context
215
- if contextFn == nil {
216
- contextFn = defaultContext
217
- }
218
- ctx , cancel := contextFn ()
219
- defer cancel ()
220
-
221
- timer := Backoff {Duration : time .Microsecond }.Timer ()
222
- attempts := 0
223
- err := loopConditionUntilContext (ctx , timer , test .immediate , test .sliding , func (_ context.Context ) (bool , error ) {
224
- attempts ++
225
- defer func () {
226
- if test .cancelContextAfter > 0 && test .cancelContextAfter == attempts {
227
- cancel ()
228
- }
229
- }()
230
- return test .callback (attempts )
231
- })
232
-
233
- if test .errExpected != err {
234
- t .Errorf ("expected error: %v but got: %v" , test .errExpected , err )
235
- }
236
-
237
- if test .attemptsExpected != attempts {
238
- t .Errorf ("expected attempts count: %d but got: %d" , test .attemptsExpected , attempts )
239
- }
240
- })
241
- })
242
- }
209
+ t .Run (test .name , func (t * testing.T ) {
210
+ contextFn := test .context
211
+ if contextFn == nil {
212
+ contextFn = defaultContext
213
+ }
214
+ ctx , cancel := contextFn ()
215
+ defer cancel ()
216
+
217
+ timer := Backoff {Duration : time .Microsecond }.Timer ()
218
+ attempts := 0
219
+ err := loopConditionUntilContext (ctx , timer , test .immediate , test .sliding , func (_ context.Context ) (bool , error ) {
220
+ attempts ++
221
+ defer func () {
222
+ if test .cancelContextAfter > 0 && test .cancelContextAfter == attempts {
223
+ cancel ()
224
+ }
225
+ }()
226
+ return test .callback (attempts )
243
227
})
244
- }
228
+
229
+ if test .errExpected != err {
230
+ t .Errorf ("expected error: %v but got: %v" , test .errExpected , err )
231
+ }
232
+
233
+ if test .attemptsExpected != attempts {
234
+ t .Errorf ("expected attempts count: %d but got: %d" , test .attemptsExpected , attempts )
235
+ }
236
+ })
245
237
}
246
238
}
247
239
0 commit comments