Added tests for custom actions (TODO_ACTIONS_DIR).
t0002-actions.sh for locating the .todo.actions.d directory. t8000-actions.sh for the contract between todo.sh and custom actions.
This commit is contained in:
40
tests/t0002-actions.sh
Executable file
40
tests/t0002-actions.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='todo.sh actions.d
|
||||
|
||||
This test just makes sure that todo.sh can locate custom actions.
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
# All the below tests will output the custom action message
|
||||
cat > expect << EOF
|
||||
TODO: foo
|
||||
EOF
|
||||
|
||||
cat > foo << EOF
|
||||
echo "TODO: foo"
|
||||
EOF
|
||||
chmod +x foo
|
||||
|
||||
test_expect_success 'custom action (default location 1)' '
|
||||
mkdir .todo.actions.d
|
||||
cp foo .todo.actions.d/
|
||||
todo.sh foo > output;
|
||||
test_cmp expect output && rm -rf .todo.actions.d
|
||||
'
|
||||
|
||||
test_expect_success 'custom action (default location 2)' '
|
||||
mkdir -p .todo/actions
|
||||
cp foo .todo/actions/
|
||||
todo.sh foo > output;
|
||||
test_cmp expect output && rm -rf .todo/actions
|
||||
'
|
||||
|
||||
test_expect_success 'custom action (env variable)' '
|
||||
mkdir myactions
|
||||
cp foo myactions/
|
||||
TODO_ACTIONS_DIR=myactions todo.sh foo > output;
|
||||
test_cmp expect output && rm -rf myactions
|
||||
'
|
||||
|
||||
test_done
|
||||
52
tests/t8000-actions.sh
Executable file
52
tests/t8000-actions.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='custom actions functionality
|
||||
|
||||
This test covers the contract between todo.sh and custom actions.
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
unset TODO_ACTIONS_DIR
|
||||
mkdir .todo.actions.d
|
||||
cat > .todo.actions.d/foo << EOF
|
||||
echo "TODO: foo"
|
||||
EOF
|
||||
|
||||
test_todo_session 'nonexecutable action' <<EOF
|
||||
>>> todo.sh foo
|
||||
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
|
||||
Try 'todo.sh -h' for more information.
|
||||
=== 1
|
||||
EOF
|
||||
|
||||
chmod +x .todo.actions.d/foo
|
||||
test_todo_session 'executable action' <<EOF
|
||||
>>> todo.sh foo
|
||||
TODO: foo
|
||||
EOF
|
||||
|
||||
cat > .todo.actions.d/ls << EOF
|
||||
echo "TODO: my ls"
|
||||
EOF
|
||||
chmod +x .todo.actions.d/ls
|
||||
test_todo_session 'overriding built-in action' <<EOF
|
||||
>>> todo.sh ls
|
||||
TODO: my ls
|
||||
|
||||
>>> todo.sh command ls
|
||||
--
|
||||
TODO: 0 of 0 tasks shown
|
||||
EOF
|
||||
|
||||
cat > .todo.actions.d/bad << EOF
|
||||
echo "TODO: bad"
|
||||
exit 42
|
||||
EOF
|
||||
chmod +x .todo.actions.d/bad
|
||||
test_todo_session 'failing action' <<EOF
|
||||
>>> todo.sh bad
|
||||
TODO: bad
|
||||
=== 42
|
||||
EOF
|
||||
|
||||
test_done
|
||||
Reference in New Issue
Block a user