Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from inkarkat/deduplicate-and-report
Deduplicate and report
- Loading branch information
Showing
5 changed files
with
312 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
test_description='archive functionality | ||
Ensure we can archive items successfully. | ||
' | ||
. ./test-lib.sh | ||
|
||
cat > todo.txt <<EOF | ||
one | ||
two | ||
three | ||
one | ||
x done | ||
four | ||
EOF | ||
|
||
test_todo_session 'archive with duplicates' <<EOF | ||
>>> todo.sh archive | ||
x done | ||
TODO: $HOME/todo.txt archived. | ||
EOF | ||
|
||
test_todo_session 'list after archive' <<EOF | ||
>>> todo.sh ls | ||
5 four | ||
1 one | ||
4 one | ||
3 three | ||
2 two | ||
-- | ||
TODO: 5 of 5 tasks shown | ||
EOF | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/bin/sh | ||
|
||
test_description='deduplicate functionality | ||
Ensure we can deduplicate items successfully. | ||
' | ||
. ./test-lib.sh | ||
|
||
cat > todo.txt <<EOF | ||
duplicated | ||
two | ||
x done | ||
duplicated | ||
double task | ||
double task | ||
three | ||
EOF | ||
|
||
test_todo_session 'deduplicate and preserve line numbers' <<EOF | ||
>>> todo.sh deduplicate | ||
TODO: 2 duplicate task(s) removed | ||
>>> todo.sh -p ls | ||
5 double task | ||
1 duplicated | ||
7 three | ||
2 two | ||
3 x done | ||
-- | ||
TODO: 5 of 5 tasks shown | ||
EOF | ||
|
||
test_todo_session 'deduplicate without duplicates' <<EOF | ||
>>> todo.sh deduplicate | ||
TODO: No duplicate tasks found | ||
EOF | ||
|
||
cat > todo.txt <<EOF | ||
duplicated | ||
two | ||
x done | ||
duplicated | ||
double task | ||
double task | ||
three | ||
EOF | ||
test_todo_session 'deduplicate and delete lines' <<EOF | ||
>>> todo.sh -n deduplicate | ||
TODO: 2 duplicate task(s) removed | ||
>>> todo.sh -p ls | ||
4 double task | ||
1 duplicated | ||
5 three | ||
2 two | ||
3 x done | ||
-- | ||
TODO: 5 of 5 tasks shown | ||
EOF | ||
|
||
cat > todo.txt <<EOF | ||
one | ||
duplicated | ||
three | ||
duplicated | ||
duplicated | ||
six | ||
duplicated | ||
EOF | ||
test_todo_session 'deduplicate more than two occurrences' <<EOF | ||
>>> todo.sh deduplicate | ||
TODO: 3 duplicate task(s) removed | ||
>>> todo.sh -p ls | ||
2 duplicated | ||
1 one | ||
6 six | ||
3 three | ||
-- | ||
TODO: 4 of 4 tasks shown | ||
EOF | ||
|
||
cat > todo.txt <<EOF | ||
normal task | ||
a [1mbold[0m task | ||
something else | ||
a [1mbold[0m task | ||
something more | ||
EOF | ||
test_todo_session 'deduplicate with non-printable duplicates' <<EOF | ||
>>> todo.sh deduplicate | ||
TODO: 1 duplicate task(s) removed | ||
>>> todo.sh -p ls | ||
2 a [1mbold[0m task | ||
1 normal task | ||
3 something else | ||
5 something more | ||
-- | ||
TODO: 4 of 4 tasks shown | ||
EOF | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/sh | ||
|
||
test_description='report functionality | ||
This test checks the reporting and the format of the report file. | ||
' | ||
. ./test-lib.sh | ||
|
||
cat > todo.txt <<EOF | ||
(B) smell the uppercase Roses +flowers @outside | ||
stop and think | ||
smell the coffee +wakeup | ||
make the coffee +wakeup | ||
visit http://example.com | ||
EOF | ||
|
||
test_todo_session 'create new report' <<EOF | ||
>>> todo.sh report | ||
TODO: $HOME/todo.txt archived. | ||
2009-02-13T04:40:00 5 0 | ||
TODO: Report file updated. | ||
>>> todo.sh -p list | ||
1 (B) smell the uppercase Roses +flowers @outside | ||
4 make the coffee +wakeup | ||
3 smell the coffee +wakeup | ||
2 stop and think | ||
5 visit http://example.com | ||
-- | ||
TODO: 5 of 5 tasks shown | ||
EOF | ||
|
||
test_todo_session 'report of done tasks' <<EOF | ||
>>> todo.sh -A do 3 | ||
3 x 2009-02-13 smell the coffee +wakeup | ||
TODO: 3 marked as done. | ||
x 2009-02-13 smell the coffee +wakeup | ||
TODO: $HOME/todo.txt archived. | ||
>>> todo.sh report | ||
TODO: $HOME/todo.txt archived. | ||
2009-02-13T04:40:00 4 1 | ||
TODO: Report file updated. | ||
>>> todo.sh -p list | ||
1 (B) smell the uppercase Roses +flowers @outside | ||
3 make the coffee +wakeup | ||
2 stop and think | ||
4 visit http://example.com | ||
-- | ||
TODO: 4 of 4 tasks shown | ||
EOF | ||
|
||
test_todo_session 'report performs archiving' <<EOF | ||
>>> todo.sh -a do 3 | ||
3 x 2009-02-13 make the coffee +wakeup | ||
TODO: 3 marked as done. | ||
>>> todo.sh report | ||
x 2009-02-13 make the coffee +wakeup | ||
TODO: $HOME/todo.txt archived. | ||
2009-02-13T04:40:00 3 2 | ||
TODO: Report file updated. | ||
>>> todo.sh -p list | ||
1 (B) smell the uppercase Roses +flowers @outside | ||
2 stop and think | ||
3 visit http://example.com | ||
-- | ||
TODO: 3 of 3 tasks shown | ||
>>> todo.sh -p listfile done.txt | ||
2 x 2009-02-13 make the coffee +wakeup | ||
1 x 2009-02-13 smell the coffee +wakeup | ||
-- | ||
DONE: 2 of 2 tasks shown | ||
EOF | ||
|
||
test_todo_session 'report is unchanged when no changes' <<EOF | ||
>>> cat report.txt | ||
2009-02-13T04:40:00 5 0 | ||
2009-02-13T04:40:00 4 1 | ||
2009-02-13T04:40:00 3 2 | ||
>>> todo.sh report | ||
TODO: $HOME/todo.txt archived. | ||
2009-02-13T04:40:00 3 2 | ||
TODO: Report file is up-to-date. | ||
>>> cat report.txt | ||
2009-02-13T04:40:00 5 0 | ||
2009-02-13T04:40:00 4 1 | ||
2009-02-13T04:40:00 3 2 | ||
EOF | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.