Refactored various add functionality to one function. Added tests.

- 'add' and 'addm' now 'addto' with $TODO_FILE instead of user supplied file

- 'addto' now shows the capitalized filename in place of 'TODO:'.
  For example, adding to garden.txt produces a output prefixed by 'GARDEN:'
  (Probably the most controversial part of this commit and up for
  discussion. If kept, the 'listfile' output should be made to match.
  Note that this convention would then minimize standard output by
  dropping the file name.)

- All existing add/addm/add-date tests pass. Two new test sequences were
  added to test 'addto' and 'listfile' functionality.

- A space/tab nuissance was cleared up in the tests/README file.
This commit is contained in:
Jared Cordasco
2010-01-10 01:16:11 -05:00
parent 394c4c748a
commit 2d3820394a
4 changed files with 171 additions and 26 deletions

78
tests/t1020-addtolistfile.sh Executable file
View File

@@ -0,0 +1,78 @@
#!/bin/sh
test_description='basic addto and list functionality
This test just makes sure the basic addto and listfile
commands work, including support for filtering.
'
. ./test-lib.sh
#
# Addto and listfile
#
test_todo_session 'nonexistant file' <<EOF
>>> todo.sh addto garden.txt notice the daisies
TODO: Destination file $HOME/garden.txt does not exist.
EOF
touch "$HOME/garden.txt"
test_todo_session 'basic addto/listfile' <<EOF
>>> todo.sh addto garden.txt notice the daisies
GARDEN: 'notice the daisies' added on line 1.
>>> todo.sh listfile garden.txt
1 notice the daisies
--
TODO: 1 of 1 tasks shown from garden.txt
>>> todo.sh addto garden.txt smell the roses
GARDEN: 'smell the roses' added on line 2.
>>> todo.sh listfile garden.txt
1 notice the daisies
2 smell the roses
--
TODO: 2 of 2 tasks shown from garden.txt
EOF
#
# Filter
#
test_todo_session 'basic listfile filtering' <<EOF
>>> todo.sh listfile garden.txt daisies
1 notice the daisies
--
TODO: 1 of 2 tasks shown from garden.txt
>>> todo.sh listfile garden.txt smell
2 smell the roses
--
TODO: 1 of 2 tasks shown from garden.txt
EOF
test_todo_session 'case-insensitive filtering' <<EOF
>>> todo.sh addto garden.txt smell the uppercase Roses
GARDEN: 'smell the uppercase Roses' added on line 3.
>>> todo.sh listfile garden.txt roses
2 smell the roses
3 smell the uppercase Roses
--
TODO: 2 of 3 tasks shown from garden.txt
EOF
test_todo_session 'addto with &' <<EOF
>>> todo.sh addto garden.txt "dig the garden & water the flowers"
GARDEN: 'dig the garden & water the flowers' added on line 4.
>>> todo.sh listfile garden.txt
4 dig the garden & water the flowers
1 notice the daisies
2 smell the roses
3 smell the uppercase Roses
--
TODO: 4 of 4 tasks shown from garden.txt
EOF
test_done