More fixes

pull/172/head
Chip Senkbeil 1 year ago
parent 34759ccdca
commit 3fb974df48
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -1,4 +1,5 @@
use crate::cli::fixtures::*;
use crate::cli::utils::missing_path_pred;
use assert_fs::prelude::*;
use predicates::prelude::*;
use rstest::*;
@ -71,7 +72,7 @@ fn yield_an_error_when_fails(ctx: DistantManagerCtx) {
.assert()
.code(1)
.stdout("")
.stderr(predicate::str::contains("No such file or directory"));
.stderr(missing_path_pred());
src.assert(predicate::path::missing());
dst.assert(predicate::path::missing());

@ -1,4 +1,5 @@
use crate::cli::fixtures::*;
use crate::cli::utils::missing_path_pred;
use assert_fs::prelude::*;
use predicates::prelude::*;
use rstest::*;
@ -51,7 +52,7 @@ fn yield_an_error_when_fails(ctx: DistantManagerCtx) {
.assert()
.code(1)
.stdout("")
.stderr(predicate::str::contains("No such file or directory"));
.stderr(missing_path_pred());
dir.assert(predicate::path::missing());
}

@ -1,6 +1,6 @@
use crate::cli::utils::missing_path_pred;
use crate::cli::{fixtures::*, utils::regex_pred};
use assert_fs::prelude::*;
use predicates::prelude::*;
use rstest::*;
const FILE_CONTENTS: &str = r#"
@ -131,5 +131,5 @@ fn yield_an_error_when_fails(ctx: DistantManagerCtx) {
.assert()
.code(1)
.stdout("")
.stderr(predicate::str::contains("No such file or directory"));
.stderr(missing_path_pred());
}

@ -1,6 +1,6 @@
use crate::cli::utils::missing_path_pred;
use crate::cli::{fixtures::*, utils::regex_pred};
use assert_fs::prelude::*;
use predicates::prelude::*;
use rstest::*;
use std::path::Path;
@ -219,5 +219,5 @@ fn yield_an_error_when_fails(ctx: DistantManagerCtx) {
.assert()
.code(1)
.stdout("")
.stderr(predicate::str::contains("No such file or directory"));
.stderr(missing_path_pred());
}

@ -1,7 +1,7 @@
use crate::cli::fixtures::*;
use crate::cli::utils::missing_path_pred;
use assert_fs::prelude::*;
use indoc::indoc;
use predicates::prelude::*;
use rstest::*;
const FILE_CONTENTS: &str = indoc! {r#"
@ -38,5 +38,5 @@ fn yield_an_error_when_fails(ctx: DistantManagerCtx) {
.assert()
.code(1)
.stdout("")
.stderr(predicate::str::contains("No such file or directory"));
.stderr(missing_path_pred());
}

@ -1,4 +1,5 @@
use crate::cli::fixtures::*;
use crate::cli::utils::directory_not_empty_pred;
use assert_fs::prelude::*;
use predicates::prelude::*;
use rstest::*;
@ -78,7 +79,7 @@ fn yield_an_error_when_fails(ctx: DistantManagerCtx) {
.assert()
.code(1)
.stdout("")
.stderr(predicate::str::contains("Directory not empty"));
.stderr(directory_not_empty_pred());
dir.assert(predicate::path::exists());
dir.assert(predicate::path::is_dir());

@ -74,7 +74,13 @@ fn yield_an_error_when_fails(ctx: DistantManagerCtx) {
.assert()
.code(1)
.stdout("")
.stderr(predicate::str::contains("No such file or directory"));
.stderr(if cfg!(unix) {
predicate::str::contains("No such file or directory")
} else if cfg!(windows) {
predicate::str::contains("The system cannot find the file specified")
} else {
unreachable!("Only other option is wasm, which is not supported")
});
src.assert(predicate::path::missing());
dst.assert(predicate::path::missing());

@ -1,7 +1,7 @@
use crate::cli::fixtures::*;
use crate::cli::utils::missing_path_pred;
use assert_fs::prelude::*;
use indoc::indoc;
use predicates::prelude::*;
use rstest::*;
const FILE_CONTENTS: &str = indoc! {r#"
@ -118,7 +118,7 @@ fn yield_an_error_when_fails(ctx: DistantManagerCtx) {
.assert()
.code(1)
.stdout("")
.stderr(predicate::str::contains("No such file or directory"));
.stderr(missing_path_pred());
// Because we're talking to a local server, we can verify locally
file.assert(predicates::path::missing());

@ -7,3 +7,25 @@ pub use reader::ThreadedReader;
pub fn regex_pred(s: &str) -> predicates::str::RegexPredicate {
predicate::str::is_match(s).unwrap()
}
/// Produces a contains predicate to assert a path missing error was reported
pub fn missing_path_pred() -> predicates::str::ContainsPredicate {
if cfg!(unix) {
predicate::str::contains("No such file or directory")
} else if cfg!(windows) {
predicate::str::contains("The system cannot find the path specified")
} else {
unreachable!("Only other option is wasm, which is not supported")
}
}
/// Produces a contains predicate to assert a directory was not empty
pub fn directory_not_empty_pred() -> predicates::str::ContainsPredicate {
if cfg!(unix) {
predicate::str::contains("Directory not empty")
} else if cfg!(windows) {
predicate::str::contains("The directory is not empty")
} else {
unreachable!("Only other option is wasm, which is not supported")
}
}

Loading…
Cancel
Save