You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
distant/tests/cli/action/file_read.rs

40 lines
1.0 KiB
Rust

use crate::cli::{fixtures::*, utils::FAILURE_LINE};
use assert_cmd::Command;
use assert_fs::prelude::*;
use rstest::*;
const FILE_CONTENTS: &str = r#"
some text
on multiple lines
that is a file's contents
"#;
#[rstest]
fn should_print_out_file_contents(mut action_cmd: CtxCommand<Command>) {
let temp = assert_fs::TempDir::new().unwrap();
let file = temp.child("test-file");
file.write_str(FILE_CONTENTS).unwrap();
// distant action file-read {path}
action_cmd
.args(&["file-read", file.to_str().unwrap()])
.assert()
.success()
.stdout(format!("{}\n", FILE_CONTENTS))
.stderr("");
}
#[rstest]
fn yield_an_error_when_fails(mut action_cmd: CtxCommand<Command>) {
let temp = assert_fs::TempDir::new().unwrap();
let file = temp.child("missing-file");
// distant action file-read {path}
action_cmd
.args(&["file-read", file.to_str().unwrap()])
.assert()
.code(1)
.stdout("")
.stderr(FAILURE_LINE.clone());
}