Add check_active_task function

This commit is contained in:
The Magician 2023-11-21 12:43:39 +00:00
parent 1b62d00350
commit 50ba89f20e
2 changed files with 35 additions and 0 deletions

View File

@ -10,3 +10,11 @@ taskl() {
"$@" \
list
}
check_active_task() {
taskcount="$(taskl | wc -l)"
if test "$taskcount" -eq 0; then
return 1
fi
}

View File

@ -21,3 +21,30 @@ test_taskl_runs_task_with_custom_parameters() {
assert_equals "$expected" "$result"
}
test_check_active_task_returns_1_when_no_active_task() {
fake task 'printf ""'
expected=1
check_active_task
assert_equals "$expected" "$?"
}
test_check_active_task_returns_0_when_one_active_task() {
fake taskl 'printf "28\n"'
expected=0
check_active_task
assert_equals "$expected" "$?"
}
test_check_active_task_returns_0_when_multiple_active_tasks() {
fake taskl 'printf "28\n29\n30\n"'
expected=0
check_active_task
assert_equals "$expected" "$?"
}