Bugfix: depri first checks validity of item argument syntax before searching for todo.
Added testcase for the basic depriority command.
This commit is contained in:
44
tests/t1700-depri.sh
Executable file
44
tests/t1700-depri.sh
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test_description='basic depriority functionality
|
||||||
|
'
|
||||||
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
test_todo_session 'depriority usage' <<EOF
|
||||||
|
>>> todo.sh depri B B
|
||||||
|
usage: todo.sh depri ITEM#
|
||||||
|
=== 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_todo_session 'depriority nonexistant item' <<EOF
|
||||||
|
>>> todo.sh depri 42
|
||||||
|
42: No such todo.
|
||||||
|
=== 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > todo.txt <<EOF
|
||||||
|
(B) smell the uppercase Roses +flowers @outside
|
||||||
|
(A) notice the sunflowers
|
||||||
|
stop
|
||||||
|
EOF
|
||||||
|
test_todo_session 'basic depriority' <<EOF
|
||||||
|
>>> todo.sh -p list
|
||||||
|
2 (A) notice the sunflowers
|
||||||
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
|
3 stop
|
||||||
|
--
|
||||||
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
|
>>> todo.sh depri 1
|
||||||
|
1: smell the uppercase Roses +flowers @outside
|
||||||
|
TODO: 1 deprioritized.
|
||||||
|
|
||||||
|
>>> todo.sh -p list
|
||||||
|
2 (A) notice the sunflowers
|
||||||
|
1 smell the uppercase Roses +flowers @outside
|
||||||
|
3 stop
|
||||||
|
--
|
||||||
|
TODO: 3 of 3 tasks shown
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_done
|
||||||
2
todo.sh
2
todo.sh
@@ -745,9 +745,9 @@ case $action in
|
|||||||
item=$2
|
item=$2
|
||||||
errmsg="usage: $TODO_SH depri ITEM#"
|
errmsg="usage: $TODO_SH depri ITEM#"
|
||||||
|
|
||||||
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
|
||||||
|
|
||||||
sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1
|
sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user