diff --git a/tests/actions-test-lib.sh b/tests/actions-test-lib.sh new file mode 100755 index 0000000..2928261 --- /dev/null +++ b/tests/actions-test-lib.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +make_action() +{ + unset TODO_ACTIONS_DIR + [ -d .todo.actions.d ] || mkdir .todo.actions.d + cat > ".todo.actions.d/$1" < ".todo.actions.d/$1" <<- EOF - #!/bin/bash - echo "custom action $1" -EOF -chmod +x ".todo.actions.d/$1" -} - make_action "foo" test_todo_session 'help output with custom action' <>> todo.sh -v help | sed '/^ \w/!d' diff --git a/tests/t8000-actions.sh b/tests/t8000-actions.sh index 5c8b7d5..763c4e9 100755 --- a/tests/t8000-actions.sh +++ b/tests/t8000-actions.sh @@ -4,19 +4,9 @@ test_description='custom actions functionality This test covers the contract between todo.sh and custom actions. ' +. ./actions-test-lib.sh . ./test-lib.sh -unset TODO_ACTIONS_DIR -mkdir .todo.actions.d -make_action() -{ - cat > ".todo.actions.d/$1" <<- EOF - #!/bin/bash - echo "custom action $1" -EOF -chmod +x ".todo.actions.d/$1" -} - make_action "foo" test_todo_session 'executable action' <>> todo.sh foo diff --git a/tests/t8010-listaddons.sh b/tests/t8010-listaddons.sh index 2c1dc17..ed0cb05 100755 --- a/tests/t8010-listaddons.sh +++ b/tests/t8010-listaddons.sh @@ -4,19 +4,9 @@ test_description='listaddons functionality This test checks listing of custom actions. ' +. ./actions-test-lib.sh . ./test-lib.sh -unset TODO_ACTIONS_DIR -mkdir .todo.actions.d -make_action() -{ - cat > ".todo.actions.d/$1" <<- EOF - #!/bin/bash - echo "custom action $1" -EOF -chmod +x ".todo.actions.d/$1" -} - test_todo_session 'no custom actions' <>> todo.sh listaddons EOF diff --git a/tests/t8020-actions-help.sh b/tests/t8020-actions-help.sh index 6f6746b..3d6ee1f 100755 --- a/tests/t8020-actions-help.sh +++ b/tests/t8020-actions-help.sh @@ -4,31 +4,15 @@ test_description='actions help functionality This test checks listing the usage help of a custom action. ' +. ./actions-test-lib.sh . ./test-lib.sh -unset TODO_ACTIONS_DIR test_todo_session 'custom action help with no custom action directory' <<'EOF' >>> todo.sh help foo TODO: No actions directory exists. === 1 EOF -mkdir .todo.actions.d -make_action() -{ - cat > ".todo.actions.d/$1" <