|
4 | 4 | # |
5 | 5 | # Specifically tests: |
6 | 6 | # - ticket_read_status() — reads compiled ticket status from reducer |
7 | | -# - ticket_find_open_children() — lists open child tickets of a given parent |
8 | | -# |
9 | | -# All test functions MUST FAIL until ticket-lib.sh is updated to add these functions. |
10 | 7 | # |
11 | 8 | # Usage: bash tests/scripts/test-ticket-health-guards.sh |
12 | | -# Returns: exit non-zero (RED) until ticket-lib.sh implements the helper functions. |
13 | 9 |
|
14 | 10 | # NOTE: -e is intentionally omitted — test functions return non-zero by design |
15 | 11 | # (they assert against unimplemented features). -e would abort the runner. |
@@ -125,99 +121,4 @@ test_ticket_read_status_returns_current_status() { |
125 | 121 | } |
126 | 122 | test_ticket_read_status_returns_current_status |
127 | 123 |
|
128 | | -# ── Test 2: ticket_find_open_children lists open children of a parent ────────── |
129 | | -echo "Test 2: ticket_find_open_children() function exists and lists open child tickets" |
130 | | -test_ticket_find_open_children_lists_children() { |
131 | | - _snapshot_fail |
132 | | - |
133 | | - # Source ticket-lib.sh to check if ticket_find_open_children is defined |
134 | | - # RED: ticket_find_open_children does not exist in ticket-lib.sh yet |
135 | | - local fn_exists=0 |
136 | | - (source "$TICKET_LIB" 2>/dev/null && declare -f ticket_find_open_children >/dev/null 2>&1) || fn_exists=$? |
137 | | - |
138 | | - if [ "$fn_exists" -ne 0 ]; then |
139 | | - # Function does not exist — assert failure to mark RED |
140 | | - assert_eq "ticket_find_open_children function exists in ticket-lib.sh" "exists" "missing" |
141 | | - assert_pass_if_clean "test_ticket_find_open_children_lists_children" |
142 | | - return |
143 | | - fi |
144 | | - |
145 | | - local repo |
146 | | - repo=$(_make_test_repo) |
147 | | - local tracker_dir="$repo/.tickets-tracker" |
148 | | - |
149 | | - # Create a parent ticket (epic) |
150 | | - local parent_id |
151 | | - parent_id=$(_create_ticket "$repo" epic "Parent epic ticket") |
152 | | - |
153 | | - if [ -z "$parent_id" ]; then |
154 | | - assert_eq "parent ticket created" "non-empty" "empty" |
155 | | - assert_pass_if_clean "test_ticket_find_open_children_lists_children" |
156 | | - return |
157 | | - fi |
158 | | - |
159 | | - # Create two child tickets under the parent |
160 | | - local child1_id child2_id |
161 | | - child1_id=$(_create_child_ticket "$repo" "$parent_id" "Child ticket 1") |
162 | | - child2_id=$(_create_child_ticket "$repo" "$parent_id" "Child ticket 2") |
163 | | - |
164 | | - if [ -z "$child1_id" ] || [ -z "$child2_id" ]; then |
165 | | - # If child creation with --parent is not yet implemented, the test must |
166 | | - # still fail RED (children can't be detected if they can't be created). |
167 | | - assert_eq "child tickets created with parent" "non-empty" "empty: child1=$child1_id child2=$child2_id" |
168 | | - assert_pass_if_clean "test_ticket_find_open_children_lists_children" |
169 | | - return |
170 | | - fi |
171 | | - |
172 | | - # Call ticket_find_open_children: should list both children (both are open) |
173 | | - local children_out |
174 | | - local children_exit=0 |
175 | | - children_out=$( |
176 | | - (cd "$repo" && source "$TICKET_LIB" && ticket_find_open_children "$tracker_dir" "$parent_id") |
177 | | - ) || children_exit=$? |
178 | | - |
179 | | - # Assert: exits 0 |
180 | | - assert_eq "ticket_find_open_children: exits 0" "0" "$children_exit" |
181 | | - |
182 | | - # Assert: output contains child1_id |
183 | | - if echo "$children_out" | grep -qF "$child1_id"; then |
184 | | - assert_eq "ticket_find_open_children: lists child1" "has-child1" "has-child1" |
185 | | - else |
186 | | - assert_eq "ticket_find_open_children: lists child1" "has-child1" "missing: $children_out" |
187 | | - fi |
188 | | - |
189 | | - # Assert: output contains child2_id |
190 | | - if echo "$children_out" | grep -qF "$child2_id"; then |
191 | | - assert_eq "ticket_find_open_children: lists child2" "has-child2" "has-child2" |
192 | | - else |
193 | | - assert_eq "ticket_find_open_children: lists child2" "has-child2" "missing: $children_out" |
194 | | - fi |
195 | | - |
196 | | - # Now close child1 and verify it no longer appears in open children |
197 | | - _transition_ticket "$repo" "$child1_id" "open" "closed" |
198 | | - |
199 | | - local children_after |
200 | | - local children_after_exit=0 |
201 | | - children_after=$( |
202 | | - (cd "$repo" && source "$TICKET_LIB" && ticket_find_open_children "$tracker_dir" "$parent_id") |
203 | | - ) || children_after_exit=$? |
204 | | - |
205 | | - # Assert: closed child1 is NOT in open children list |
206 | | - if echo "$children_after" | grep -qF "$child1_id"; then |
207 | | - assert_eq "ticket_find_open_children: excludes closed child1" "excludes-child1" "still-includes-child1" |
208 | | - else |
209 | | - assert_eq "ticket_find_open_children: excludes closed child1" "excludes-child1" "excludes-child1" |
210 | | - fi |
211 | | - |
212 | | - # Assert: open child2 still appears |
213 | | - if echo "$children_after" | grep -qF "$child2_id"; then |
214 | | - assert_eq "ticket_find_open_children: still lists open child2" "has-child2" "has-child2" |
215 | | - else |
216 | | - assert_eq "ticket_find_open_children: still lists open child2" "has-child2" "missing: $children_after" |
217 | | - fi |
218 | | - |
219 | | - assert_pass_if_clean "test_ticket_find_open_children_lists_children" |
220 | | -} |
221 | | -test_ticket_find_open_children_lists_children |
222 | | - |
223 | 124 | print_summary |
0 commit comments