Verify that check_active_task only counts active tasks

This commit is contained in:
The Magician 2023-11-21 13:23:20 +00:00
parent 0a3f02198f
commit e5bf621ec8
2 changed files with 15 additions and 1 deletions

View File

@ -11,8 +11,12 @@ taskl() {
list list
} }
get_active_task_count() {
taskl +ACTIVE | wc -l
}
check_active_task() { check_active_task() {
taskcount="$(taskl +ACTIVE | wc -l)" taskcount="$(get_active_task_count)"
if test "$taskcount" -eq 0; then if test "$taskcount" -eq 0; then
return 1 return 1

View File

@ -22,6 +22,16 @@ test_taskl_runs_task_with_custom_parameters() {
assert_equals "$expected" "$result" assert_equals "$expected" "$result"
} }
test_get_active_task_count_calls_taskl_with_correct_filter() {
fake taskl 'echo "taskl ${FAKE_PARAMS[@]}"'
fake wc 'cat'
expected="taskl +ACTIVE"
result="$(get_active_task_count)"
assert_equals "$expected" "$result"
}
test_check_active_task_returns_1_when_no_active_task() { test_check_active_task_returns_1_when_no_active_task() {
fake task 'printf ""' fake task 'printf ""'
expected=1 expected=1