forked from pimterry/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-find.bats
executable file
·92 lines (67 loc) · 1.96 KB
/
test-find.bats
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
#!./test/libs/bats/bin/bats
load 'helpers'
setup() {
setupNotesEnv
}
teardown() {
teardownNotesEnv
}
notes="./notes"
@test "Should output nothing and return non-zero if there are no notes to find" {
run $notes find
assert_failure
echo $output
assert_equal $(echo $output | wc -w) 0
}
@test "Should show all notes found if no pattern is provided to find" {
touch $NOTES_DIRECTORY/note1.md
touch $NOTES_DIRECTORY/note2.md
run $notes find
assert_success
assert_line "note1.md"
assert_line "note2.md"
}
@test "Should find notes when using the find shorthand alias" {
touch $NOTES_DIRECTORY/note.md
run $notes f
assert_success
assert_line "note.md"
}
@test "Should show matching notes only if a pattern is provided to find" {
touch $NOTES_DIRECTORY/match-note1.md
touch $NOTES_DIRECTORY/hide-note2.md
run $notes find "match"
assert_success
assert_line "match-note1.md"
refute_line "hide-note2.md"
}
@test "Should match notes case insensitively with find" {
touch $NOTES_DIRECTORY/MATCH-note1.md
touch $NOTES_DIRECTORY/hide-note2.md
run $notes find "match"
assert_success
assert_line "MATCH-note1.md"
refute_line "hide-note2.md"
}
@test "Should match subdirectory or file names with find" {
touch "$NOTES_DIRECTORY/hide-note.md"
mkdir "$NOTES_DIRECTORY/match-directory"
touch "$NOTES_DIRECTORY/match-directory/note.md"
run $notes find "match"
assert_success
assert_output "match-directory/note.md"
}
@test "Should find files inside subdirectories with spaces" {
mkdir "$NOTES_DIRECTORY/path with spaces"
touch "$NOTES_DIRECTORY/path with spaces/note.md"
run $notes find
assert_success
assert_output "path with spaces/note.md"
}
@test "Should find files inside notes directories with spaces" {
mkdir "$NOTES_DIRECTORY/path with spaces"
touch "$NOTES_DIRECTORY/path with spaces/note.md"
NOTES_DIRECTORY="$NOTES_DIRECTORY/path with spaces" run $notes find
assert_success
assert_output "note.md"
}