Skip to content

Commit

Permalink
Reorganize imports to be more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
svenstaro committed Jan 10, 2025
1 parent 996ac30 commit 4dc6346
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 78 deletions.
12 changes: 6 additions & 6 deletions tests/archive.rs
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down
13 changes: 6 additions & 7 deletions tests/auth.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
11 changes: 5 additions & 6 deletions tests/auth_file.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
10 changes: 6 additions & 4 deletions tests/bind.rs
Original file line number Diff line number Diff line change
@@ -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"])]
Expand Down
8 changes: 5 additions & 3 deletions tests/cli.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
18 changes: 11 additions & 7 deletions tests/create_directories.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
5 changes: 3 additions & 2 deletions tests/header.rs
Original file line number Diff line number Diff line change
@@ -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()]),
Expand Down
13 changes: 7 additions & 6 deletions tests/navigation.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
15 changes: 8 additions & 7 deletions tests/qrcode.rs
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down
16 changes: 8 additions & 8 deletions tests/raw.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
12 changes: 7 additions & 5 deletions tests/readme.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
18 changes: 10 additions & 8 deletions tests/serve_request.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
7 changes: 4 additions & 3 deletions tests/tls.rs
Original file line number Diff line number Diff line change
@@ -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(&[
Expand Down
10 changes: 6 additions & 4 deletions tests/upload_files.rs
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down
2 changes: 0 additions & 2 deletions tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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();

Expand Down

0 comments on commit 4dc6346

Please sign in to comment.