Add pick_random_task_id function

This commit is contained in:
The Magician 2023-11-21 13:06:31 +00:00
parent 50ba89f20e
commit dffaa3a901
2 changed files with 15 additions and 0 deletions

View File

@ -18,3 +18,8 @@ check_active_task() {
return 1 return 1
fi fi
} }
pick_random_task_id() {
task_id="$(taskl | shuf | head -n 1)"
echo "$task_id"
}

View File

@ -48,3 +48,13 @@ test_check_active_task_returns_0_when_multiple_active_tasks() {
assert_equals "$expected" "$?" assert_equals "$expected" "$?"
} }
test_pick_random_task_id_picks_random_id() {
fake taskl 'printf "28\n29\n30\n"'
fake shuf 'head -n 1'
expected="28"
result="$(pick_random_task_id)"
assert_equals "$expected" "$result"
}