Add pick_random_task_id function
This commit is contained in:
parent
50ba89f20e
commit
dffaa3a901
|
@ -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"
|
||||||
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue