Shorten --max-time in tests and use a more stable error check (#14494)

- fixes flakey tests from solving #14241

# Description
This is a preliminary fix for the flaky tests and also
shortened the `--max-time` in the tests.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->



---------

Signed-off-by: Alex Kattathra Johnson <alex.kattathra.johnson@gmail.com>
This commit is contained in:
Alex Kattathra Johnson
2024-12-06 06:03:13 -06:00
committed by GitHub
parent 81d68cd478
commit cda9ae1e42
7 changed files with 69 additions and 24 deletions

View File

@ -50,14 +50,21 @@ fn http_options_timeout() {
let _mock = server
.mock("OPTIONS", "/")
.with_chunked_body(|w| {
thread::sleep(Duration::from_secs(1));
thread::sleep(Duration::from_secs(10));
w.write_all(b"Delayed response!")
})
.create();
let actual = nu!(pipeline(
format!("http options --max-time 500ms {url}", url = server.url()).as_str()
format!("http options --max-time 100ms {url}", url = server.url()).as_str()
));
assert!(&actual.err.contains("nu::shell::io_error"));
assert!(&actual.err.contains("nu::shell::network_failure"));
#[cfg(not(target_os = "windows"))]
assert!(&actual.err.contains("timed out reading response"));
#[cfg(target_os = "windows")]
assert!(&actual
.err
.contains("did not properly respond after a period of time"));
}