Add check_active_task function
This commit is contained in:
parent
1b62d00350
commit
50ba89f20e
|
@ -10,3 +10,11 @@ taskl() {
|
|||
"$@" \
|
||||
list
|
||||
}
|
||||
|
||||
check_active_task() {
|
||||
taskcount="$(taskl | wc -l)"
|
||||
|
||||
if test "$taskcount" -eq 0; then
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -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" "$?"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue