mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Refactor send_request in client.rs (#13701)
Closes #13687 Closes #13686 # Description Light refactoring of `send_request `in `client.rs`. In the end there are more lines but now the logic is more concise and facilitates adding new conditions in the future. Unit tests ran fine and I tested a few cases manually. Cool project btw, I'll be using nushell from now on.
This commit is contained in:
@ -133,6 +133,36 @@ fn http_post_json_list_is_success() {
|
||||
assert!(actual.out.is_empty())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn http_post_json_int_is_success() {
|
||||
let mut server = Server::new();
|
||||
|
||||
let mock = server.mock("POST", "/").match_body(r#"50"#).create();
|
||||
|
||||
let actual = nu!(format!(
|
||||
r#"http post -t 'application/json' {url} 50"#,
|
||||
url = server.url()
|
||||
));
|
||||
|
||||
mock.assert();
|
||||
assert!(actual.out.is_empty())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn http_post_json_string_is_success() {
|
||||
let mut server = Server::new();
|
||||
|
||||
let mock = server.mock("POST", "/").match_body(r#""test""#).create();
|
||||
|
||||
let actual = nu!(format!(
|
||||
r#"http post -t 'application/json' {url} "test""#,
|
||||
url = server.url()
|
||||
));
|
||||
|
||||
mock.assert();
|
||||
assert!(actual.out.is_empty())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn http_post_follows_redirect() {
|
||||
let mut server = Server::new();
|
||||
|
Reference in New Issue
Block a user