forked from pimterry/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-append.bats
executable file
·68 lines (50 loc) · 1.24 KB
/
test-append.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
#!./test/libs/bats/bin/bats
load 'helpers'
setup() {
setupNotesEnv
}
teardown() {
teardownNotesEnv
}
notes="./notes"
@test "Appends a note with a message from commandline" {
$notes append note.md Test
run $notes cat note.md
assert_success
assert_output $'Test'
}
@test "Doesn't override a file, it actually appends" {
$notes append note.md Test1
$notes append note.md Test2
run $notes cat note.md
assert_success
assert_output $'Test1\nTest2'
}
@test "Accepts input from stdin pipe" {
echo "Echo Test" | $notes append note.md
run $notes cat note.md
assert_success
assert_output $'Echo Test'
}
@test "Works with more than one word given via commandline" {
$notes append note.md Multi word test
run $notes cat note.md
assert_success
assert_output $'Multi word test'
}
@test "Fails when no message is given" {
run $notes append note.md
assert_failure
assert_output $'No text was provided to append'
}
@test "Shortname works to invoke append" {
$notes a note.md Test
run $notes cat note.md
assert_success
assert_output $'Test'
}
@test "Should complain and ask for a name if one is not provided" {
run $notes append
assert_failure
assert_line "Append requires a name, but none was provided."
}