aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2025-01-10 16:23:00 +0000
committerSven-Hendrik Haase <svenstaro@gmail.com>2025-01-10 16:23:00 +0000
commit4dc634655edac54e9638e8390d89a96e235522c0 (patch)
tree15f8cc8bdb2046a70a5f7552964f1781dfced72c
parentRemove some unnecessary #[allow(dead_code)] (diff)
downloadminiserve-4dc634655edac54e9638e8390d89a96e235522c0.tar.gz
miniserve-4dc634655edac54e9638e8390d89a96e235522c0.zip
Reorganize imports to be more consistent
-rw-r--r--tests/archive.rs12
-rw-r--r--tests/auth.rs13
-rw-r--r--tests/auth_file.rs11
-rw-r--r--tests/bind.rs10
-rw-r--r--tests/cli.rs8
-rw-r--r--tests/create_directories.rs18
-rw-r--r--tests/header.rs5
-rw-r--r--tests/navigation.rs13
-rw-r--r--tests/qrcode.rs15
-rw-r--r--tests/raw.rs16
-rw-r--r--tests/readme.rs12
-rw-r--r--tests/serve_request.rs18
-rw-r--r--tests/tls.rs7
-rw-r--r--tests/upload_files.rs10
-rw-r--r--tests/utils/mod.rs2
15 files changed, 92 insertions, 78 deletions
diff --git a/tests/archive.rs b/tests/archive.rs
index e6d0263..5f34ade 100644
--- a/tests/archive.rs
+++ b/tests/archive.rs
@@ -1,10 +1,10 @@
-mod fixtures;
-
-use fixtures::{server, Error, TestServer};
-use reqwest::StatusCode;
+use reqwest::StatusCode;
use rstest::rstest;
-use select::document::Document;
-use select::predicate::Text;
+use select::{document::Document, predicate::Text};
+
+mod fixtures;
+
+use crate::fixtures::{server, Error, TestServer};
#[rstest]
fn archives_are_disabled(server: TestServer) -> Result<(), Error> {
diff --git a/tests/auth.rs b/tests/auth.rs
index 920f738..6c5a6ad 100644
--- a/tests/auth.rs
+++ b/tests/auth.rs
@@ -1,12 +1,11 @@
-mod fixtures;
-
-use fixtures::{server, server_no_stderr, Error, FILES};
use pretty_assertions::assert_eq;
-use reqwest::blocking::Client;
-use reqwest::StatusCode;
+use reqwest::{blocking::Client, StatusCode};
use rstest::rstest;
-use select::document::Document;
-use select::predicate::Text;
+use select::{document::Document, predicate::Text};
+
+mod fixtures;
+
+use crate::fixtures::{server, server_no_stderr, Error, FILES};
#[rstest(
cli_auth_arg, client_username, client_password,
diff --git a/tests/auth_file.rs b/tests/auth_file.rs
index 15af8f1..10a94ed 100644
--- a/tests/auth_file.rs
+++ b/tests/auth_file.rs
@@ -1,11 +1,10 @@
+use reqwest::{blocking::Client, StatusCode};
+use rstest::rstest;
+use select::{document::Document, predicate::Text};
+
mod fixtures;
-use fixtures::{server, server_no_stderr, Error, FILES};
-use reqwest::blocking::Client;
-use reqwest::StatusCode;
-use rstest::rstest;
-use select::document::Document;
-use select::predicate::Text;
+use crate::fixtures::{server, server_no_stderr, Error, FILES};
#[rstest(
cli_auth_file_arg,
diff --git a/tests/bind.rs b/tests/bind.rs
index 0fa914e..e6c448a 100644
--- a/tests/bind.rs
+++ b/tests/bind.rs
@@ -1,12 +1,14 @@
-mod fixtures;
+use std::io::{BufRead, BufReader};
+use std::process::{Command, Stdio};
use assert_cmd::prelude::*;
use assert_fs::fixture::TempDir;
-use fixtures::{port, server, tmpdir, Error, TestServer};
use regex::Regex;
use rstest::rstest;
-use std::io::{BufRead, BufReader};
-use std::process::{Command, Stdio};
+
+mod fixtures;
+
+use crate::fixtures::{port, server, tmpdir, Error, TestServer};
#[rstest]
#[case(&["-i", "12.123.234.12"])]
diff --git a/tests/cli.rs b/tests/cli.rs
index 8ec03a8..7c53698 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -1,10 +1,12 @@
-mod fixtures;
+use std::process::Command;
use assert_cmd::prelude::*;
use clap::{crate_name, crate_version, ValueEnum};
use clap_complete::Shell;
-use fixtures::Error;
-use std::process::Command;
+
+mod fixtures;
+
+use crate::fixtures::Error;
#[test]
/// Show help and exit.
diff --git a/tests/create_directories.rs b/tests/create_directories.rs
index 380c796..c15b40f 100644
--- a/tests/create_directories.rs
+++ b/tests/create_directories.rs
@@ -1,15 +1,19 @@
-mod fixtures;
-
-use fixtures::{server, Error, TestServer, DIRECTORIES};
-use reqwest::blocking::{multipart, Client};
-use rstest::rstest;
-use select::document::Document;
-use select::predicate::{Attr, Text};
#[cfg(unix)]
use std::os::unix::fs::symlink as symlink_dir;
#[cfg(windows)]
use std::os::windows::fs::symlink_dir;
+use reqwest::blocking::{multipart, Client};
+use rstest::rstest;
+use select::{
+ document::Document,
+ predicate::{Attr, Text},
+};
+
+mod fixtures;
+
+use crate::fixtures::{server, Error, TestServer, DIRECTORIES};
+
/// This should work because the flags for uploading files and creating directories
/// are set, and the directory name and path are valid.
#[rstest]
diff --git a/tests/header.rs b/tests/header.rs
index 4ac38b1..ea4c462 100644
--- a/tests/header.rs
+++ b/tests/header.rs
@@ -1,7 +1,8 @@
+use rstest::rstest;
+
mod fixtures;
-use fixtures::{server, Error};
-use rstest::rstest;
+use crate::fixtures::{server, Error};
#[rstest(headers,
case(vec!["x-info: 123".to_string()]),
diff --git a/tests/navigation.rs b/tests/navigation.rs
index c8fd494..f061d30 100644
--- a/tests/navigation.rs
+++ b/tests/navigation.rs
@@ -1,13 +1,14 @@
-mod fixtures;
-mod utils;
+use std::process::{Command, Stdio};
-use fixtures::{server, Error, TestServer, DEEPLY_NESTED_FILE, DIRECTORIES};
use pretty_assertions::{assert_eq, assert_ne};
use rstest::rstest;
use select::document::Document;
-use std::process::{Command, Stdio};
-use utils::get_link_from_text;
-use utils::get_link_hrefs_with_prefix;
+
+mod fixtures;
+mod utils;
+
+use crate::fixtures::{server, Error, TestServer, DEEPLY_NESTED_FILE, DIRECTORIES};
+use crate::utils::{get_link_from_text, get_link_hrefs_with_prefix};
#[rstest(
input,
diff --git a/tests/qrcode.rs b/tests/qrcode.rs
index 48fa8c8..6951d7a 100644
--- a/tests/qrcode.rs
+++ b/tests/qrcode.rs
@@ -1,14 +1,15 @@
-mod fixtures;
+use std::process::{Command, Stdio};
+use std::thread::sleep;
+use std::time::Duration;
use assert_cmd::prelude::CommandCargoExt;
use assert_fs::TempDir;
-use fixtures::{port, server, tmpdir, Error, TestServer};
use rstest::rstest;
-use select::document::Document;
-use select::predicate::Attr;
-use std::process::{Command, Stdio};
-use std::thread::sleep;
-use std::time::Duration;
+use select::{document::Document, predicate::Attr};
+
+mod fixtures;
+
+use crate::fixtures::{port, server, tmpdir, Error, TestServer};
#[rstest]
fn webpage_hides_qrcode_when_disabled(server: TestServer) -> Result<(), Error> {
diff --git a/tests/raw.rs b/tests/raw.rs
index 95100d2..0017bae 100644
--- a/tests/raw.rs
+++ b/tests/raw.rs
@@ -1,14 +1,14 @@
-mod fixtures;
-mod utils;
-
-use crate::fixtures::TestServer;
-use fixtures::{server, Error};
use pretty_assertions::assert_eq;
use reqwest::blocking::Client;
use rstest::rstest;
-use select::document::Document;
-use select::predicate::Class;
-use select::predicate::Name;
+use select::{
+ document::Document,
+ predicate::{Class, Name},
+};
+
+mod fixtures;
+
+use crate::fixtures::{server, Error, TestServer};
/// The footer displays the correct wget command to download the folder recursively
// This test can't test all aspects of the wget footer,
diff --git a/tests/readme.rs b/tests/readme.rs
index c8138b4..122f6ec 100644
--- a/tests/readme.rs
+++ b/tests/readme.rs
@@ -1,12 +1,14 @@
-mod fixtures;
+use std::fs::{remove_file, File};
+use std::io::Write;
+use std::path::PathBuf;
-use fixtures::{server, Error, TestServer, DIRECTORIES, FILES};
use rstest::rstest;
use select::predicate::Attr;
use select::{document::Document, node::Node};
-use std::fs::{remove_file, File};
-use std::io::Write;
-use std::path::PathBuf;
+
+mod fixtures;
+
+use fixtures::{server, Error, TestServer, DIRECTORIES, FILES};
fn write_readme_contents(path: PathBuf, filename: &str) -> PathBuf {
let readme_path = path.join(filename);
diff --git a/tests/serve_request.rs b/tests/serve_request.rs
index e5f098e..f536200 100644
--- a/tests/serve_request.rs
+++ b/tests/serve_request.rs
@@ -1,18 +1,20 @@
-mod fixtures;
+use std::process::{Command, Stdio};
+use std::thread::sleep;
+use std::time::Duration;
use assert_cmd::prelude::*;
use assert_fs::fixture::TempDir;
-use fixtures::{
- port, server, server_no_stderr, tmpdir, Error, TestServer, DIRECTORIES, FILES,
- HIDDEN_DIRECTORIES, HIDDEN_FILES,
-};
use regex::Regex;
use reqwest::StatusCode;
use rstest::rstest;
use select::{document::Document, node::Node, predicate::Attr};
-use std::process::{Command, Stdio};
-use std::thread::sleep;
-use std::time::Duration;
+
+mod fixtures;
+
+use crate::fixtures::{
+ port, server, server_no_stderr, tmpdir, Error, TestServer, DIRECTORIES, FILES,
+ HIDDEN_DIRECTORIES, HIDDEN_FILES,
+};
#[cfg(unix)]
use std::os::unix::fs::{symlink as symlink_dir, symlink as symlink_file};
diff --git a/tests/tls.rs b/tests/tls.rs
index 7750c82..9cc441c 100644
--- a/tests/tls.rs
+++ b/tests/tls.rs
@@ -1,12 +1,13 @@
-mod fixtures;
-
use assert_cmd::Command;
-use fixtures::{server, Error, TestServer, FILES};
use predicates::str::contains;
use reqwest::blocking::ClientBuilder;
use rstest::rstest;
use select::{document::Document, node::Node};
+mod fixtures;
+
+use crate::fixtures::{server, Error, TestServer, FILES};
+
/// Can start the server with TLS and receive encrypted responses.
#[rstest]
#[case(server(&[
diff --git a/tests/upload_files.rs b/tests/upload_files.rs
index 77a9dc3..72548e4 100644
--- a/tests/upload_files.rs
+++ b/tests/upload_files.rs
@@ -1,13 +1,15 @@
-mod fixtures;
+use std::fs::create_dir_all;
+use std::path::Path;
use assert_fs::fixture::TempDir;
-use fixtures::{server, server_no_stderr, tmpdir, Error, TestServer};
use reqwest::blocking::{multipart, Client};
use rstest::rstest;
use select::document::Document;
use select::predicate::{Attr, Text};
-use std::fs::create_dir_all;
-use std::path::Path;
+
+mod fixtures;
+
+use crate::fixtures::{server, server_no_stderr, tmpdir, Error, TestServer};
#[rstest]
fn uploading_files_works(#[with(&["-u"])] server: TestServer) -> Result<(), Error> {
diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs
index c392b14..792b070 100644
--- a/tests/utils/mod.rs
+++ b/tests/utils/mod.rs
@@ -4,7 +4,6 @@ use select::predicate::Name;
use select::predicate::Predicate;
/// Return the href attribute content for the closest anchor found by `text`.
-#[allow(dead_code)]
pub fn get_link_from_text(document: &Document, text: &str) -> Option<String> {
let a_elem = document
.find(Name("a").and(|x: &Node| x.children().any(|x| x.text() == text)))
@@ -13,7 +12,6 @@ pub fn get_link_from_text(document: &Document, text: &str) -> Option<String> {
}
/// Return the href attributes of all links that start with the specified `prefix`.
-#[allow(dead_code)]
pub fn get_link_hrefs_with_prefix(document: &Document, prefix: &str) -> Vec<String> {
let mut vec: Vec<String> = Vec::new();