@@ -237,8 +237,8 @@ mod tests {
237
237
fn check_seconds_left_and_elapsed_time_are_used_by_the_formatter ( ) {
238
238
// 4 steps
239
239
let progress_bar = ProgressBar :: new ( 4 ) ;
240
- // 1 step done in 15 ms, left 45ms to finish the 4th steps
241
- sleep ( Duration :: from_millis ( 15 ) ) ;
240
+ // 1 step done in 150 ms, left 450ms to finish the 4th steps
241
+ sleep ( Duration :: from_millis ( 150 ) ) ;
242
242
progress_bar. set_position ( 1 ) ;
243
243
244
244
let json_string = ProgressBarJsonFormatter :: format ( & progress_bar) ;
@@ -247,19 +247,19 @@ mod tests {
247
247
let milliseconds_elapsed = progress_bar. elapsed ( ) . as_millis ( ) ;
248
248
249
249
// Milliseconds in json may not be exactly the same as the one we get because of the test duration.
250
- // We need to have a difference not more than 4ms to keep the same 2 first milliseconds digits.
251
- let delta = 4 ;
250
+ // We need to have a difference not more than 49ms to keep the same 1 first milliseconds digits.
251
+ let delta = 49 ;
252
252
253
- assert ! ( ( ( 45 - delta) ..=( 45 + delta) ) . contains( & milliseconds_left) ) ;
253
+ assert ! ( ( ( 450 - delta) ..=( 450 + delta) ) . contains( & milliseconds_left) ) ;
254
254
assert ! (
255
- json_string. contains( r#""seconds_left": 0.04 "# ) , // Should be close to 0.045
255
+ json_string. contains( r#""seconds_left": 0.4 "# ) , // Should be close to 0.450
256
256
"Not expected value in json output: {}" ,
257
257
json_string
258
258
) ;
259
259
260
- assert ! ( ( ( 15 - delta) ..( 15 + delta) ) . contains( & milliseconds_elapsed) ) ;
260
+ assert ! ( ( ( 150 - delta) ..( 150 + delta) ) . contains( & milliseconds_elapsed) ) ;
261
261
assert ! (
262
- json_string. contains( r#""seconds_elapsed": 0.01 "# ) , // Should be close to 0.015
262
+ json_string. contains( r#""seconds_elapsed": 0.1 "# ) , // Should be close to 0.150
263
263
"Not expected value in json output: {}" ,
264
264
json_string
265
265
) ;
0 commit comments