mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit Tests
- Added sample hooks that behave/misbehave in various ways.
This commit is contained in:
parent
1cfdfbae52
commit
3ff42af9c7
22 changed files with 421 additions and 0 deletions
19
test/test_hooks/on-add-accept
Normal file
19
test/test_hooks/on-add-accept
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-add event is triggered separately for each task added. This hook
|
||||
# script can accept/reject the addition. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - Line of JSON for proposed new task.
|
||||
read new_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo $new_task
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
17
test/test_hooks/on-add-misbehave1
Normal file
17
test/test_hooks/on-add-misbehave1
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-add event is triggered separately for each task added. This hook
|
||||
# script can accept/reject the addition. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - Line of JSON for proposed new task.
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 1
|
17
test/test_hooks/on-add-misbehave2
Normal file
17
test/test_hooks/on-add-misbehave2
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-add event is triggered separately for each task added. This hook
|
||||
# script can accept/reject the addition. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - Line of JSON for proposed new task.
|
||||
read new_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
20
test/test_hooks/on-add-misbehave3
Normal file
20
test/test_hooks/on-add-misbehave3
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-add event is triggered separately for each task added. This hook
|
||||
# script can accept/reject the addition. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - Line of JSON for proposed new task.
|
||||
read new_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo $new_task
|
||||
echo '{"description":"extra","status":"pending"}'
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
19
test/test_hooks/on-add-misbehave4
Normal file
19
test/test_hooks/on-add-misbehave4
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-add event is triggered separately for each task added. This hook
|
||||
# script can accept/reject the addition. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - Line of JSON for proposed new task.
|
||||
read new_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo '{"description":"different","status":"pending"}'
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
19
test/test_hooks/on-add-misbehave5
Normal file
19
test/test_hooks/on-add-misbehave5
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-add event is triggered separately for each task added. This hook
|
||||
# script can accept/reject the addition. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - Line of JSON for proposed new task.
|
||||
read new_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo '{"}'
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
19
test/test_hooks/on-add-misbehave6
Normal file
19
test/test_hooks/on-add-misbehave6
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-add event is triggered separately for each task added. This hook
|
||||
# script can accept/reject the addition. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - Line of JSON for proposed new task.
|
||||
read new_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo '{"description":"invalid"}'
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
19
test/test_hooks/on-add-reject
Normal file
19
test/test_hooks/on-add-reject
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-add event is triggered separately for each task added. This hook
|
||||
# script can accept/reject the addition. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - Line of JSON for proposed new task.
|
||||
read new_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo $new_task
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 1
|
20
test/test_hooks/on-exit-bad
Normal file
20
test/test_hooks/on-exit-bad
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-exit event is triggered once, after all processing is complete.
|
||||
# This hooks script has no effect on processing.
|
||||
|
||||
# Input:
|
||||
# - Read-only line of JSON for each task added/modified
|
||||
while read modified_task
|
||||
do
|
||||
echo 'CHANGED TASK'
|
||||
done
|
||||
|
||||
# Output:
|
||||
# - Optional feedback/error.
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON ignored, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 1
|
20
test/test_hooks/on-exit-good
Normal file
20
test/test_hooks/on-exit-good
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-exit event is triggered once, after all processing is complete.
|
||||
# This hooks script has no effect on processing.
|
||||
|
||||
# Input:
|
||||
# - Read-only line of JSON for each task added/modified
|
||||
while read modified_task
|
||||
do
|
||||
echo 'CHANGED TASK'
|
||||
done
|
||||
|
||||
# Output:
|
||||
# - Optional feedback/error.
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON ignored, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
16
test/test_hooks/on-exit-misbehave1
Normal file
16
test/test_hooks/on-exit-misbehave1
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-exit event is triggered once, after all processing is complete.
|
||||
# This hooks script has no effect on processing.
|
||||
|
||||
# Input:
|
||||
# - Read-only line of JSON for each task added/modified
|
||||
|
||||
# Output:
|
||||
# - Optional feedback/error.
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON ignored, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
17
test/test_hooks/on-launch-bad
Normal file
17
test/test_hooks/on-launch-bad
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-launch event is triggered once, after initialization, before any
|
||||
# processing occurs. This hooks script has no effect on processing.
|
||||
|
||||
# Input:
|
||||
# - None
|
||||
|
||||
# Output:
|
||||
# - Optional feedback/error.
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON ignored, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 1
|
||||
|
17
test/test_hooks/on-launch-good
Normal file
17
test/test_hooks/on-launch-good
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-launch event is triggered once, after initialization, before any
|
||||
# processing occurs. This hooks script has no effect on processing.
|
||||
|
||||
# Input:
|
||||
# - None
|
||||
|
||||
# Output:
|
||||
# - Optional feedback/error.
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON ignored, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
||||
|
18
test/test_hooks/on-launch-misbehave1
Normal file
18
test/test_hooks/on-launch-misbehave1
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-launch event is triggered once, after initialization, before any
|
||||
# processing occurs. This hooks script has no effect on processing.
|
||||
|
||||
# Input:
|
||||
# - None
|
||||
|
||||
# Output:
|
||||
# - Optional feedback/error.
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON ignored, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
kill -9 $$
|
||||
exit 0
|
||||
|
21
test/test_hooks/on-modify-accept
Normal file
21
test/test_hooks/on-modify-accept
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-modify event is triggered separately for each task modified. This hook
|
||||
# script can accept/reject the modification. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - line of JSON for the original task
|
||||
# - line of JSON for the modified task, the diff being the modification
|
||||
read original_task
|
||||
read modified_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo $modified_task
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
18
test/test_hooks/on-modify-misbehave1
Normal file
18
test/test_hooks/on-modify-misbehave1
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-modify event is triggered separately for each task modified. This hook
|
||||
# script can accept/reject the modification. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - line of JSON for the original task
|
||||
# - line of JSON for the modified task, the diff being the modification
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 1
|
19
test/test_hooks/on-modify-misbehave2
Normal file
19
test/test_hooks/on-modify-misbehave2
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-modify event is triggered separately for each task modified. This hook
|
||||
# script can accept/reject the modification. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - line of JSON for the original task
|
||||
# - line of JSON for the modified task, the diff being the modification
|
||||
read original_task
|
||||
read modified_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
22
test/test_hooks/on-modify-misbehave3
Normal file
22
test/test_hooks/on-modify-misbehave3
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-modify event is triggered separately for each task modified. This hook
|
||||
# script can accept/reject the modification. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - line of JSON for the original task
|
||||
# - line of JSON for the modified task, the diff being the modification
|
||||
read original_task
|
||||
read modified_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo $modified_task
|
||||
echo '{"description":"extra","status":"pending"}'
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
21
test/test_hooks/on-modify-misbehave4
Normal file
21
test/test_hooks/on-modify-misbehave4
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-modify event is triggered separately for each task modified. This hook
|
||||
# script can accept/reject the modification. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - line of JSON for the original task
|
||||
# - line of JSON for the modified task, the diff being the modification
|
||||
read original_task
|
||||
read modified_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo '{"description":"different","status":"pending"}'
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
21
test/test_hooks/on-modify-misbehave5
Normal file
21
test/test_hooks/on-modify-misbehave5
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-modify event is triggered separately for each task modified. This hook
|
||||
# script can accept/reject the modification. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - line of JSON for the original task
|
||||
# - line of JSON for the modified task, the diff being the modification
|
||||
read original_task
|
||||
read modified_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo '{"}'
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
21
test/test_hooks/on-modify-misbehave6
Normal file
21
test/test_hooks/on-modify-misbehave6
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-modify event is triggered separately for each task modified. This hook
|
||||
# script can accept/reject the modification. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - line of JSON for the original task
|
||||
# - line of JSON for the modified task, the diff being the modification
|
||||
read original_task
|
||||
read modified_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo '{"description":"invalid"}'
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 0
|
21
test/test_hooks/on-modify-reject
Normal file
21
test/test_hooks/on-modify-reject
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
# The on-modify event is triggered separately for each task modified. This hook
|
||||
# script can accept/reject the modification. Processing will continue.
|
||||
|
||||
# Input:
|
||||
# - line of JSON for the original task
|
||||
# - line of JSON for the modified task, the diff being the modification
|
||||
read original_task
|
||||
read modified_task
|
||||
|
||||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo $modified_task
|
||||
echo 'FEEDBACK'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
# - non-0: JSON ignored, non-JSON is error.
|
||||
exit 1
|
Loading…
Add table
Add a link
Reference in a new issue