aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Cargo.lock41
-rw-r--r--Cargo.toml2
-rw-r--r--tests/cli.rs44
3 files changed, 38 insertions, 49 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ba0fcfd..d72d5ef 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -120,7 +120,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -497,7 +497,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -636,7 +636,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1103,7 +1103,7 @@ dependencies = [
"port_check 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
- "rstest 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rstest 0.2.2 (git+https://github.com/la10736/rstest.git)",
"select 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"simplelog 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1698,11 +1698,13 @@ dependencies = [
[[package]]
name = "rstest"
version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
+source = "git+https://github.com/la10736/rstest.git#949e34ac50dbde94bbcac3a2c0db51bce3ba5510"
dependencies = [
+ "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1818,7 +1820,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1955,7 +1957,7 @@ dependencies = [
"heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1971,7 +1973,7 @@ dependencies = [
"heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1986,17 +1988,7 @@ dependencies = [
[[package]]
name = "syn"
-version = "0.14.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "syn"
-version = "0.15.32"
+version = "0.15.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2019,7 +2011,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2504,7 +2496,7 @@ dependencies = [
"nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.28 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -2819,7 +2811,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum reqwest 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)" = "943b9f85622f53bcf71721e0996f23688e3942e51fc33766c2e24a959316767b"
"checksum resolv-conf 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b263b4aa1b5de9ffc0054a2386f96992058bb6870aab516f8cdeb8a667d56dcb"
"checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a"
-"checksum rstest 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "17060b44b74f0aed4e7ee6c970e57b5e51adbd3aecd814e1ab38a27e00901d67"
+"checksum rstest 0.2.2 (git+https://github.com/la10736/rstest.git)" = "<none>"
"checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288"
"checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
@@ -2856,8 +2848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum strum 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1c33039533f051704951680f1adfd468fd37ac46816ded0d9ee068e60f05f"
"checksum strum_macros 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "47cd23f5c7dee395a00fa20135e2ec0fffcdfa151c56182966d7a3261343432e"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
-"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
-"checksum syn 0.15.32 (registry+https://github.com/rust-lang/crates.io-index)" = "846620ec526c1599c070eff393bfeeeb88a93afa2513fc3b49f1fea84cf7b0ed"
+"checksum syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)" = "ec52cd796e5f01d0067225a5392e70084acc4c0013fa71d55166d38a8b307836"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
"checksum tar 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)" = "8acf894d8bd30d060f3a8e457463f341ccabe475329e0670896de56e29e11b49"
diff --git a/Cargo.toml b/Cargo.toml
index 0708a8f..cef92a6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -52,5 +52,5 @@ reqwest = "0.9"
assert_fs = "0.11"
select = "0.4"
port_check = "0.1"
-rstest = "0.2"
+rstest = { git = "https://github.com/la10736/rstest.git" }
pretty_assertions = "0.6"
diff --git a/tests/cli.rs b/tests/cli.rs
index 6a41764..2390c3b 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -3,9 +3,9 @@ use assert_fs::fixture::TempDir;
use assert_fs::prelude::*;
use clap::{crate_name, crate_version};
use port_check::free_local_port;
-use pretty_assertions::assert_eq;
use reqwest;
use reqwest::multipart;
+use rstest::rstest;
use select::document::Document;
use select::predicate::{Attr, Text};
use std::process::{Command, Stdio};
@@ -17,17 +17,24 @@ type Error = Box<std::error::Error>;
static FILES: &[&str] = &["test.txt", "test.html", "test.mkv"];
/// Test fixture which creates a temporary directory with a few files inside.
-pub fn tmpdir() -> Result<TempDir, Error> {
- let tmpdir = assert_fs::TempDir::new()?;
+pub fn tmpdir() -> TempDir {
+ let tmpdir = assert_fs::TempDir::new().expect("Couldn't create a temp dir for tests");
for &file in FILES {
- tmpdir.child(file).write_str("Test Hello Yes")?;
+ tmpdir
+ .child(file)
+ .write_str("Test Hello Yes")
+ .expect("Couldn't write to file");
}
- Ok(tmpdir)
+ tmpdir
}
-#[test]
-fn serves_requests_with_no_options() -> Result<(), Error> {
- let tmpdir = tmpdir()?;
+/// Get a free port.
+pub fn port() -> u16 {
+ free_local_port().expect("Couldn't find a free local port")
+}
+
+#[rstest]
+fn serves_requests_with_no_options(tmpdir: TempDir) -> Result<(), Error> {
let mut child = Command::cargo_bin("miniserve")?
.arg(tmpdir.path())
.stdout(Stdio::null())
@@ -46,11 +53,8 @@ fn serves_requests_with_no_options() -> Result<(), Error> {
Ok(())
}
-#[test]
-fn serves_requests_with_non_default_port() -> Result<(), Error> {
- let tmpdir = tmpdir()?;
-
- let port = free_local_port().unwrap();
+#[rstest]
+fn serves_requests_with_non_default_port(tmpdir: TempDir, port: u16) -> Result<(), Error> {
let mut child = Command::cargo_bin("miniserve")?
.arg(tmpdir.path())
.arg("-p")
@@ -71,11 +75,8 @@ fn serves_requests_with_non_default_port() -> Result<(), Error> {
Ok(())
}
-#[test]
-fn auth_works() -> Result<(), Error> {
- let tmpdir = tmpdir()?;
-
- let port = free_local_port().unwrap();
+#[rstest]
+fn auth_works(tmpdir: TempDir, port: u16) -> Result<(), Error> {
let mut child = Command::cargo_bin("miniserve")?
.arg(tmpdir.path())
.arg("-p")
@@ -103,13 +104,10 @@ fn auth_works() -> Result<(), Error> {
Ok(())
}
-#[test]
-fn uploading_files_works() -> Result<(), Error> {
- let tmpdir = tmpdir()?;
-
+#[rstest]
+fn uploading_files_works(tmpdir: TempDir, port: u16) -> Result<(), Error> {
let test_file_name = "uploaded test file.txt";
- let port = free_local_port().unwrap();
let mut child = Command::cargo_bin("miniserve")?
.arg(tmpdir.path())
.arg("-p")