test: 🎨 fix clippy style and tests, add an inode test

inode: 🔨 only get inode on unix, return 0 for windows
This commit is contained in:
zwPapEr
2019-12-07 11:22:00 +08:00
committed by Abin Simon
parent 0ebb39d60c
commit da2e2081e3
2 changed files with 53 additions and 6 deletions

View File

@@ -19,13 +19,34 @@ fn test_list_empty_directory() {
.stdout(predicate::eq(""));
}
#[test]
fn test_list_almost_all_empty_directory() {
cmd()
.arg("--almost-all")
.arg(tempdir().path())
.assert()
.stdout(predicate::eq(""));
cmd()
.arg("-A")
.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"));
.stdout(predicate::str::is_match(".* \\.\n.* \\.\\.\n$").unwrap());
cmd()
.arg("-a")
.arg(tempdir().path())
.assert()
.stdout(predicate::str::is_match(".* \\.\n.* \\.\\.\n$").unwrap());
}
#[test]
@@ -36,7 +57,19 @@ fn test_list_populated_directory() {
cmd()
.arg(dir.path())
.assert()
.stdout(predicate::eq("one\ntwo\n"));
.stdout(predicate::str::is_match(".* one\n.* two\n$").unwrap());
}
#[test]
fn test_list_almost_all_populated_directory() {
let dir = tempdir();
dir.child("one").touch().unwrap();
dir.child("two").touch().unwrap();
cmd()
.arg("--almost-all")
.arg(dir.path())
.assert()
.stdout(predicate::str::is_match(".* one\n.* two\n$").unwrap());
}
#[test]
@@ -48,7 +81,21 @@ fn test_list_all_populated_directory() {
.arg("--all")
.arg(dir.path())
.assert()
.stdout(predicate::eq(".\n..\none\ntwo\n"));
.stdout(predicate::str::is_match(".* \\.\n.* \\.\\.\n.* one\n.* two\n$").unwrap());
}
#[test]
#[cfg(unix)]
fn test_list_inode_populated_directory() {
let dir = tempdir();
dir.child("one").touch().unwrap();
dir.child("two").touch().unwrap();
cmd()
.arg("--blocks")
.arg("inode,name")
.arg(dir.path())
.assert()
.stdout(predicate::str::is_match("\\d+ one\n\\d+ two\n$").unwrap());
}
fn cmd() -> Command {