-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonenote_test
76 lines (63 loc) · 2.12 KB
/
onenote_test
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
#!/usr/bin/env bash
# Leverages the basht testing library:
# https://github.com/progrium/basht
progname="onenote"
executable="$(pwd)/${progname}"
newline="###NEWLINE###"
export ONENOTE_TEST_HARNESS=1
export ONENOTE_PIPE_EDITOR="cat"
T_noArgsReturnsError() {
${executable} > /dev/null
[[ $? -eq 1 ]]
}
T_moreThanTwoArgsReturnsError() {
${executable} 1 2 3 > /dev/null
[[ $? -eq 1 ]]
}
T_twoArgsIncorrectSecondArgReturnsError() {
${executable} 1 2 > /dev/null
[[ $? -eq 1 ]]
}
T_correctArgsNoUdaNotesReturnsError() {
ONENOTE_MISSING_NOTES="1" ${executable} 1 > /dev/null
[[ $? -eq 1 ]]
}
T_validTaskWithNoNotesReturnsEmptyNote() {
export ONENOTE_TEST_NOTES=""
result="$(${executable} 1)"
echo "No notes result: ${result}"
[[ "${result}" = "${ONENOTE_TEST_NOTES}" ]]
}
T_validTaskWithNotesReturnsValidFormattedNote() {
export ONENOTE_TEST_NOTES="foo\nbar\n\nbaz"
result="$(${executable} 1)"
echo "With notes result: ${result}"
[[ "${result}" = "${ONENOTE_TEST_NOTES}" ]]
}
T_validTaskWithNotesAndNewlineMarkerReturnsValidFormattedNote() {
export ONENOTE_TEST_NOTES="foo${newline}bar${newline}${newline}baz"
result="$(${executable} 1)"
echo "With notes result: ${result}"
[[ "${result}" = "${ONENOTE_TEST_NOTES}" ]]
}
T_validTaskWithNoNotesWithDefaultContentReturnsNoteWithDefaultContent() {
export ONENOTE_TEST_NOTES=""
export ONENOTE_DEFAULT_CONTENT="test"
result="$(${executable} 1)"
echo "No notes with default content result: ${result}"
[[ "${result}" = "${ONENOTE_DEFAULT_CONTENT}" ]]
}
T_validTaskWithNotesWithDefaultContentReturnsValidFormattedNote() {
export ONENOTE_TEST_NOTES="foo\nbar\n\nbaz"
export ONENOTE_DEFAULT_CONTENT="test"
result="$(${executable} 1)"
echo "With notes with default content result: ${result}"
[[ "${result}" = "${ONENOTE_TEST_NOTES}" ]]
}
T_validTaskWithNotesWithDefaultContentAndNewlineMarkerReturnsValidFormattedNote() {
export ONENOTE_TEST_NOTES="foo${newline}bar${newline}${newline}baz"
export ONENOTE_DEFAULT_CONTENT="test"
result="$(${executable} 1)"
echo "With notes with default content result: ${result}"
[[ "${result}" = "${ONENOTE_TEST_NOTES}" ]]
}