mirror of
https://github.com/lsd-rs/lsd.git
synced 2026-04-21 10:57:36 +02:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user