From 67b2ec8e70d0f781b3f57762c1e8e28c2102c15d Mon Sep 17 00:00:00 2001 From: khai96_ Date: Sat, 4 May 2019 13:36:32 +0700 Subject: Add assertion of status code to auth_works --- tests/auth.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/auth.rs') diff --git a/tests/auth.rs b/tests/auth.rs index f43553b..af2db58 100644 --- a/tests/auth.rs +++ b/tests/auth.rs @@ -43,11 +43,15 @@ fn auth_works( sleep(Duration::from_secs(1)); let client = reqwest::Client::new(); - let body = client + let response = client .get(format!("http://localhost:{}", port).as_str()) .basic_auth(client_username, Some(client_password)) - .send()? - .error_for_status()?; + .send()?; + + let status_code = response.status(); + assert_eq!(status_code.canonical_reason(), Some("OK")); + + let body = response.error_for_status()?; let parsed = Document::from_read(body)?; for &file in FILES { assert!(parsed.find(Text).any(|x| x.text() == file)); -- cgit v1.2.3 From 03b4cbad39e17cc6f083b77801177daba101d169 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Mon, 6 May 2019 21:02:19 +0700 Subject: Use constant for assertion --- tests/auth.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/auth.rs') diff --git a/tests/auth.rs b/tests/auth.rs index af2db58..9882a39 100644 --- a/tests/auth.rs +++ b/tests/auth.rs @@ -9,6 +9,7 @@ use select::predicate::Text; use std::process::{Command, Stdio}; use std::thread::sleep; use std::time::Duration; +use reqwest::StatusCode; #[rstest_parametrize( cli_auth_arg, client_username, client_password, @@ -49,7 +50,7 @@ fn auth_works( .send()?; let status_code = response.status(); - assert_eq!(status_code.canonical_reason(), Some("OK")); + assert_eq!(status_code, StatusCode::OK); let body = response.error_for_status()?; let parsed = Document::from_read(body)?; -- cgit v1.2.3