11#! /usr/bin/env bash
22
3- test_description=' addp command functionality
3+ test_description=' addpri command functionality
44
5- Tests the addp command which adds tasks with specified priority.
5+ Tests the addpri command which adds tasks with specified priority.
66'
77. ./test-lib.sh
88
9- # Test basic addp functionality
10- test_todo_session ' basic addp functionality' << EOF
11- >>> todo.sh addp A "High priority task"
9+ # Test basic addpri functionality
10+ test_todo_session ' basic addpri functionality' << EOF
11+ >>> todo.sh addpri A "High priority task"
12121 (A) High priority task
1313TODO: 1 added.
1414
15- >>> todo.sh addp B "Medium priority task"
15+ >>> todo.sh addpri B "Medium priority task"
16162 (B) Medium priority task
1717TODO: 2 added.
1818
19- >>> todo.sh addp Z "Low priority task"
19+ >>> todo.sh addpri Z "Low priority task"
20203 (Z) Low priority task
2121TODO: 3 added.
2222
3232cat > todo.txt << EOF
3333EOF
3434test_todo_session ' lowercase priority conversion' << EOF
35- >>> todo.sh addp c "lowercase priority test"
35+ >>> todo.sh addpri c "lowercase priority test"
36361 (C) lowercase priority test
3737TODO: 1 added.
3838
39- >>> todo.sh addp z "another lowercase test"
39+ >>> todo.sh addpri z "another lowercase test"
40402 (Z) another lowercase test
4141TODO: 2 added.
4242
@@ -47,15 +47,15 @@ TODO: 2 added.
4747TODO: 2 of 2 tasks shown
4848EOF
4949
50- # Test addp with projects and contexts
50+ # Test addpri with projects and contexts
5151cat > todo.txt << EOF
5252EOF
53- test_todo_session ' addp with projects and contexts' << EOF
54- >>> todo.sh addp A "Important work task +project @work"
53+ test_todo_session ' addpri with projects and contexts' << EOF
54+ >>> todo.sh addpri A "Important work task +project @work"
55551 (A) Important work task +project @work
5656TODO: 1 added.
5757
58- >>> todo.sh addp B "Call client +client @phone"
58+ >>> todo.sh addpri B "Call client +client @phone"
59592 (B) Call client +client @phone
6060TODO: 2 added.
6161
6969# Test error handling - no arguments
7070cat > todo.txt << EOF
7171EOF
72- test_todo_session ' addp error - no arguments' << EOF
73- >>> todo.sh addp
74- usage: todo.sh addp PRIORITY "TODO ITEM"
72+ test_todo_session ' addpri error - no arguments' << EOF
73+ >>> todo.sh addpri
74+ usage: todo.sh addpri PRIORITY "TODO ITEM"
7575=== 1
7676EOF
7777
7878# Test error handling - missing task text
79- test_todo_session ' addp error - missing task text' << EOF
80- >>> todo.sh addp A
81- usage: todo.sh addp PRIORITY "TODO ITEM"
79+ test_todo_session ' addpri error - missing task text' << EOF
80+ >>> todo.sh addpri A
81+ usage: todo.sh addpri PRIORITY "TODO ITEM"
8282=== 1
8383EOF
8484
8585# Test error handling - invalid priority (number)
86- test_todo_session ' addp error - invalid priority number' << EOF
87- >>> todo.sh addp 1 "Invalid priority task"
86+ test_todo_session ' addpri error - invalid priority number' << EOF
87+ >>> todo.sh addpri 1 "Invalid priority task"
8888TODO: Priority must be a letter from A to Z (got: 1)
8989=== 1
9090EOF
9191
9292# Test error handling - invalid priority (multiple characters)
93- test_todo_session ' addp error - invalid priority multiple chars' << EOF
94- >>> todo.sh addp AA "Invalid priority task"
93+ test_todo_session ' addpri error - invalid priority multiple chars' << EOF
94+ >>> todo.sh addpri AA "Invalid priority task"
9595TODO: Priority must be a letter from A to Z (got: AA)
9696=== 1
9797EOF
9898
9999# Test error handling - invalid priority (special character)
100- test_todo_session ' addp error - invalid priority special char' << EOF
101- >>> todo.sh addp @ "Invalid priority task"
100+ test_todo_session ' addpri error - invalid priority special char' << EOF
101+ >>> todo.sh addpri @ "Invalid priority task"
102102TODO: Priority must be a letter from A to Z (got: @)
103103=== 1
104104EOF
105105
106- # Test addp integration with date_on_add
106+ # Test addpri integration with date_on_add
107107cat > todo.txt << EOF
108108EOF
109109echo " export TODOTXT_DATE_ON_ADD=1" >> todo.cfg
110110
111- test_todo_session ' addp with date on add' << EOF
112- >>> todo.sh addp A "Task with date"
113- 1 (A) $( date ' +%Y-%m-%d ' ) Task with date
111+ test_todo_session ' addpri with date on add' << EOF
112+ >>> todo.sh addpri A "Task with date"
113+ 1 (A) 2009-02-13 Task with date
114114TODO: 1 added.
115115
116116>>> todo.sh -p list
117- 1 (A) $( date ' +%Y-%m-%d ' ) Task with date
117+ 1 (A) 2009-02-13 Task with date
118118--
119119TODO: 1 of 1 tasks shown
120120EOF
121121
122122# Reset config for next test
123123echo " export TODOTXT_DATE_ON_ADD=0" >> todo.cfg
124124
125- # Test that addp overrides TODOTXT_PRIORITY_ON_ADD
125+ # Test that addpri overrides TODOTXT_PRIORITY_ON_ADD
126126cat > todo.txt << EOF
127127EOF
128128echo " export TODOTXT_PRIORITY_ON_ADD=C" >> todo.cfg
129129
130- test_todo_session ' addp overrides PRIORITY_ON_ADD' << EOF
131- >>> todo.sh addp A "Priority A task"
130+ test_todo_session ' addpri overrides PRIORITY_ON_ADD' << EOF
131+ >>> todo.sh addpri A "Priority A task"
1321321 (A) Priority A task
133133TODO: 1 added.
134134
@@ -143,15 +143,15 @@ TODO: 2 added.
143143TODO: 2 of 2 tasks shown
144144EOF
145145
146- # Test addp with various edge cases
146+ # Test addpri with various edge cases
147147cat > todo.txt << EOF
148148EOF
149- test_todo_session ' addp edge cases' << EOF
150- >>> todo.sh addp E "Task with special chars: !@#$%^&*()"
149+ test_todo_session ' addpri edge cases' << EOF
150+ >>> todo.sh addpri E "Task with special chars: !@#$%^&*()"
1511511 (E) Task with special chars: !@#$%^&*()
152152TODO: 1 added.
153153
154- >>> todo.sh addp F "Task with 'single quotes' and \"double quotes\""
154+ >>> todo.sh addpri F "Task with 'single quotes' and \"double quotes\""
1551552 (F) Task with 'single quotes' and "double quotes"
156156TODO: 2 added.
157157
0 commit comments