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:
Ingo Karkat
2010-05-25 13:08:27 +02:00
parent 370abbbf36
commit 5876cc0437
2 changed files with 45 additions and 1 deletions

44
tests/t1700-depri.sh Executable file
View 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

View File

@@ -745,9 +745,9 @@ case $action in
item=$2
errmsg="usage: $TODO_SH depri ITEM#"
[[ "$item" = +([0-9]) ]] || die "$errmsg"
todo=$(sed "$item!d" "$TODO_FILE")
[ -z "$todo" ] && die "$item: No such todo."
[[ "$item" = +([0-9]) ]] || die "$errmsg"
sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1