forked from pimterry/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-rm.bats
executable file
·102 lines (78 loc) · 2.28 KB
/
test-rm.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
93
94
95
96
97
98
99
100
101
102
#!./test/libs/bats/bin/bats
load 'helpers'
setup() {
setupNotesEnv
}
teardown() {
teardownNotesEnv
}
notes="./notes"
@test "Should remove created note" {
touch "$NOTES_DIRECTORY/note.md"
run $notes rm note
assert_success
refute_exists "$NOTES_DIRECTORY/note.md"
}
@test "Should fail to delete non-existent note" {
run $notes rm note
assert_failure
}
@test "Should fail when no file or folder given" {
run $notes rm
assert_failure
}
@test "Should remove note in folder" {
mkdir "$NOTES_DIRECTORY/folder"
touch "$NOTES_DIRECTORY/folder/note.md"
run $notes rm folder/note
assert_success
refute_exists "$NOTES_DIRECTORY/folder/note.md"
}
@test "Should fail to remove folder" {
mkdir "$NOTES_DIRECTORY/folder"
run $notes rm folder
assert_failure
assert_exists "$NOTES_DIRECTORY/folder"
}
@test "-r Should remove folder recursively" {
mkdir "$NOTES_DIRECTORY/folder"
touch "$NOTES_DIRECTORY/folder/note.md"
run $notes rm -r folder
assert_success
refute_exists "$NOTES_DIRECTORY/folder"
refute_exists "$NOTES_DIRECTORY/folder/note.md"
}
@test "-r Should fail if no file or folder given" {
mkdir "$NOTES_DIRECTORY/folder"
touch "$NOTES_DIRECTORY/folder/note.md"
run $notes rm -r
assert_failure
assert_line "Remove requires a file or folder, but none was provided."
assert_exists "$NOTES_DIRECTORY/folder"
assert_exists "$NOTES_DIRECTORY/folder/note.md"
}
@test "--recursive Should remove folder recursively" {
mkdir "$NOTES_DIRECTORY/folder"
touch "$NOTES_DIRECTORY/folder/note.md"
run $notes rm --recursive folder
assert_success
refute_exists "$NOTES_DIRECTORY/folder"
refute_exists "$NOTES_DIRECTORY/folder/note.md"
}
@test "--recursive Should fail if no file or folder given" {
mkdir "$NOTES_DIRECTORY/folder"
touch "$NOTES_DIRECTORY/folder/note.md"
run $notes rm --recursive
assert_failure
assert_line "Remove requires a file or folder, but none was provided."
assert_exists "$NOTES_DIRECTORY/folder"
assert_exists "$NOTES_DIRECTORY/folder/note.md"
}
@test "should delete file if both folder and file exists" {
mkdir "$NOTES_DIRECTORY/folder"
touch "$NOTES_DIRECTORY/folder.md"
run $notes rm --recursive folder
assert_success
assert_exists "$NOTES_DIRECTORY/folder"
refute_exists "$NOTES_DIRECTORY/folder.md"
}