From 57f02a1587555176f1b43b001e7846ac9eb2e949 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Thu, 6 Feb 2025 05:18:20 +0100 Subject: Clean up and modernize rstest usage We still had some old-style syntax in there. --- tests/auth_file.rs | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'tests/auth_file.rs') diff --git a/tests/auth_file.rs b/tests/auth_file.rs index eb40d2c..5632d46 100644 --- a/tests/auth_file.rs +++ b/tests/auth_file.rs @@ -4,22 +4,17 @@ use select::{document::Document, predicate::Text}; mod fixtures; -use crate::fixtures::{server, Error, FILES}; +use crate::fixtures::{server, Error, TestServer, FILES}; -#[rstest( - cli_auth_file_arg, - client_username, - client_password, - case("tests/data/auth1.txt", "joe", "123"), - case("tests/data/auth1.txt", "bob", "123"), - case("tests/data/auth1.txt", "bill", "") -)] +#[rstest] +#[case("joe", "123")] +#[case("bob", "123")] +#[case("bill", "")] fn auth_file_accepts( - cli_auth_file_arg: &str, - client_username: &str, - client_password: &str, + #[with(&["--auth-file", "tests/data/auth1.txt"])] server: TestServer, + #[case] client_username: &str, + #[case] client_password: &str, ) -> Result<(), Error> { - let server = server(&["--auth-file", cli_auth_file_arg]); let client = Client::new(); let response = client .get(server.url()) @@ -38,20 +33,15 @@ fn auth_file_accepts( Ok(()) } -#[rstest( - cli_auth_file_arg, - client_username, - client_password, - case("tests/data/auth1.txt", "joe", "wrongpassword"), - case("tests/data/auth1.txt", "bob", ""), - case("tests/data/auth1.txt", "nonexistentuser", "wrongpassword") -)] +#[rstest] +#[case("joe", "wrongpassword")] +#[case("bob", "")] +#[case("nonexistentuser", "wrongpassword")] fn auth_file_rejects( - cli_auth_file_arg: &str, - client_username: &str, - client_password: &str, + #[with(&["--auth-file", "tests/data/auth1.txt"])] server: TestServer, + #[case] client_username: &str, + #[case] client_password: &str, ) -> Result<(), Error> { - let server = server(&["--auth-file", cli_auth_file_arg]); let client = Client::new(); let status = client .get(server.url()) -- cgit v1.2.3