mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-13 21:52:37 +00:00
61 lines
1.2 KiB
Rust
61 lines
1.2 KiB
Rust
|
extern crate assert_cmd;
|
||
|
extern crate predicates;
|
||
|
|
||
|
use assert_cmd::prelude::*;
|
||
|
use assert_fs::prelude::*;
|
||
|
use predicates::prelude::*;
|
||
|
use std::process::Command;
|
||
|
|
||
|
#[test]
|
||
|
fn test_runs_okay() {
|
||
|
cmd().assert().success();
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_list_empty_directory() {
|
||
|
cmd()
|
||
|
.arg(tempdir().path())
|
||
|
.assert()
|
||
|
.stdout(predicate::eq(""));
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_list_all_empty_directory() {
|
||
|
cmd()
|
||
|
.arg("--all")
|
||
|
.arg(tempdir().path())
|
||
|
.assert()
|
||
|
.stdout(predicate::eq(".\n..\n"));
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_list_populated_directory() {
|
||
|
let dir = tempdir();
|
||
|
dir.child("one").touch().unwrap();
|
||
|
dir.child("two").touch().unwrap();
|
||
|
cmd()
|
||
|
.arg(dir.path())
|
||
|
.assert()
|
||
|
.stdout(predicate::eq("one\ntwo\n"));
|
||
|
}
|
||
|
|
||
|
#[test]
|
||
|
fn test_list_all_populated_directory() {
|
||
|
let dir = tempdir();
|
||
|
dir.child("one").touch().unwrap();
|
||
|
dir.child("two").touch().unwrap();
|
||
|
cmd()
|
||
|
.arg("--all")
|
||
|
.arg(dir.path())
|
||
|
.assert()
|
||
|
.stdout(predicate::eq(".\n..\none\ntwo\n"));
|
||
|
}
|
||
|
|
||
|
fn cmd() -> Command {
|
||
|
Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap()
|
||
|
}
|
||
|
|
||
|
fn tempdir() -> assert_fs::TempDir {
|
||
|
assert_fs::TempDir::new().unwrap()
|
||
|
}
|