blob: 96ac61e88b3821ae0b6902b35dbc58a24aa91ee0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
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_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::str::is_match(".* \\.\n.* \\.\\.\n$").unwrap());
cmd()
.arg("-a")
.arg(tempdir().path())
.assert()
.stdout(predicate::str::is_match(".* \\.\n.* \\.\\.\n$").unwrap());
}
#[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::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]
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::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 {
Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap()
}
fn tempdir() -> assert_fs::TempDir {
assert_fs::TempDir::new().unwrap()
}
|