forked from todotxt/todo.txt-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
t0000-config.sh
executable file
·61 lines (51 loc) · 1.59 KB
/
t0000-config.sh
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
#!/bin/sh
test_description='todo.sh configuration file location
This test just makes sure that todo.sh can find its
config files in the default locations and take arguments
to find it somewhere else.
'
. ./test-lib.sh
# Remove the pre-created todo.cfg to test behavior in its absence
rm -f todo.cfg
echo "Fatal error: Cannot read configuration file $HOME/todo.cfg" > expect
test_expect_success 'no config file' '
todo.sh > output 2>&1 || test_cmp expect output
'
# All the below tests will output the usage message.
cat > expect << EOF
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
Try 'todo.sh -h' for more information.
EOF
cat > test.cfg << EOF
export TODO_DIR=.
export TODO_FILE="$TODO_DIR/todo.txt"
export DONE_FILE="$TODO_DIR/done.txt"
export REPORT_FILE="$TODO_DIR/report.txt"
export TMP_FILE="$TODO_DIR/todo.tmp"
touch used_config
EOF
rm -f used_config
test_expect_success 'config file (default location 1)' '
cp test.cfg todo.cfg
todo.sh > output;
test_cmp expect output && test -f used_config &&
rm -f todo.cfg
'
rm -f used_config
test_expect_success 'config file (default location 2)' '
cp test.cfg .todo.cfg
todo.sh > output;
test_cmp expect output && test -f used_config &&
rm -f .todo.cfg
'
rm -f used_config
test_expect_success 'config file (command line)' '
todo.sh -d test.cfg > output;
test_cmp expect output && test -f used_config
'
rm -f used_config
test_expect_success 'config file (env variable)' '
TODOTXT_CFG_FILE=test.cfg todo.sh > output;
test_cmp expect output && test -f used_config
'
test_done