@@ -248,6 +248,92 @@ func TestEdit_NoFlags(t *testing.T) {
248248 }
249249}
250250
251+ func TestEdit_BlockedBy (t * testing.T ) {
252+ ts := startTestServer (t )
253+ setClientEnv (t , ts .URL )
254+
255+ // Create two beads
256+ out := runCmd (t , "add" , "Blocker bead" )
257+ blocker := parseBeadFromOutput (t , out )
258+
259+ out = runCmd (t , "add" , "Blocked bead" )
260+ blocked := parseBeadFromOutput (t , out )
261+
262+ // Use edit --blocked-by to add the dependency
263+ out = runCmd (t , "edit" , blocked .ID , "--blocked-by" , blocker .ID )
264+ edited := parseBeadFromOutput (t , out )
265+
266+ if len (edited .BlockedBy ) != 1 || edited .BlockedBy [0 ] != blocker .ID {
267+ t .Errorf ("blocked_by = %v, want [%s]" , edited .BlockedBy , blocker .ID )
268+ }
269+ }
270+
271+ func TestEdit_BlockedByWithOtherFields (t * testing.T ) {
272+ ts := startTestServer (t )
273+ setClientEnv (t , ts .URL )
274+
275+ out := runCmd (t , "add" , "Blocker" )
276+ blocker := parseBeadFromOutput (t , out )
277+
278+ out = runCmd (t , "add" , "Target" )
279+ target := parseBeadFromOutput (t , out )
280+
281+ // Edit title and add dependency in one command
282+ out = runCmd (t , "edit" , target .ID , "--title" , "Updated target" , "--blocked-by" , blocker .ID )
283+ edited := parseBeadFromOutput (t , out )
284+
285+ if edited .Title != "Updated target" {
286+ t .Errorf ("title = %q, want %q" , edited .Title , "Updated target" )
287+ }
288+ if len (edited .BlockedBy ) != 1 || edited .BlockedBy [0 ] != blocker .ID {
289+ t .Errorf ("blocked_by = %v, want [%s]" , edited .BlockedBy , blocker .ID )
290+ }
291+ }
292+
293+ func TestEdit_BlockedByMultiple (t * testing.T ) {
294+ ts := startTestServer (t )
295+ setClientEnv (t , ts .URL )
296+
297+ out := runCmd (t , "add" , "Blocker A" )
298+ blockerA := parseBeadFromOutput (t , out )
299+
300+ out = runCmd (t , "add" , "Blocker B" )
301+ blockerB := parseBeadFromOutput (t , out )
302+
303+ out = runCmd (t , "add" , "Target" )
304+ target := parseBeadFromOutput (t , out )
305+
306+ // Comma-separated
307+ out = runCmd (t , "edit" , target .ID , "--blocked-by" , blockerA .ID + "," + blockerB .ID )
308+ edited := parseBeadFromOutput (t , out )
309+
310+ if len (edited .BlockedBy ) != 2 {
311+ t .Fatalf ("blocked_by = %v, want 2 entries" , edited .BlockedBy )
312+ }
313+ }
314+
315+ func TestEdit_BlockedByRepeatedFlag (t * testing.T ) {
316+ ts := startTestServer (t )
317+ setClientEnv (t , ts .URL )
318+
319+ out := runCmd (t , "add" , "Blocker A" )
320+ blockerA := parseBeadFromOutput (t , out )
321+
322+ out = runCmd (t , "add" , "Blocker B" )
323+ blockerB := parseBeadFromOutput (t , out )
324+
325+ out = runCmd (t , "add" , "Target" )
326+ target := parseBeadFromOutput (t , out )
327+
328+ // Repeated --blocked-by flags
329+ out = runCmd (t , "edit" , target .ID , "--blocked-by" , blockerA .ID , "--blocked-by" , blockerB .ID )
330+ edited := parseBeadFromOutput (t , out )
331+
332+ if len (edited .BlockedBy ) != 2 {
333+ t .Fatalf ("blocked_by = %v, want 2 entries" , edited .BlockedBy )
334+ }
335+ }
336+
251337func TestClean_RemovesClosedBeads (t * testing.T ) {
252338 ts := startTestServer (t )
253339 setClientEnv (t , ts .URL )
0 commit comments