From bc0849e96fe41e509af4306c0953f463a7fad155 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 23 Mar 2026 13:35:07 +0200 Subject: fix: accept uuid: prefix on all ask subcommands via NormalizeUUID All ask commands now strip a leading "uuid:" prefix from user-supplied UUID arguments before building the taskwarrior filter, so both bare UUIDs and the "uuid:" format work uniformly across annotate, start, stop, done, modify, denotate, priority, tag, info, delete, and dep. Co-Authored-By: Claude Sonnet 4.6 --- internal/askcli/command_dep_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'internal/askcli/command_dep_test.go') diff --git a/internal/askcli/command_dep_test.go b/internal/askcli/command_dep_test.go index b059dd8..6139afa 100644 --- a/internal/askcli/command_dep_test.go +++ b/internal/askcli/command_dep_test.go @@ -67,6 +67,39 @@ func TestHandleDep_UnknownOp(t *testing.T) { } } +// TestHandleDep_AcceptUUIDPrefix verifies that dep add/rm/list accept the +// "uuid:" prefix on both UUID arguments and strip it before building the filter. +func TestHandleDep_AcceptUUIDPrefix(t *testing.T) { + testCases := []struct { + name string + args []string + wantArg0 string + }{ + {"add with prefix", []string{"dep", "add", "uuid:uuid-1", "uuid:uuid-2"}, "uuid:uuid-1"}, + {"rm with prefix", []string{"dep", "rm", "uuid:uuid-1", "uuid:uuid-2"}, "uuid:uuid-1"}, + {"list with prefix", []string{"dep", "list", "uuid:uuid-1"}, "uuid:uuid-1"}, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + var capturedArgs []string + export := `[{"uuid":"uuid-1","description":"T","status":"pending","priority":"M","tags":[],"urgency":0,"depends":[]}]` + d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { + capturedArgs = args + io.WriteString(stdout, export) + return 0, nil + }}) + var stdout, stderr bytes.Buffer + code, _ := d.Dispatch(context.Background(), tc.args, nil, &stdout, &stderr) + if code != 0 { + t.Fatalf("%s code = %d stderr = %s", tc.name, code, stderr.String()) + } + if len(capturedArgs) == 0 || capturedArgs[0] != tc.wantArg0 { + t.Fatalf("%s capturedArgs[0] = %q, want %q (full: %v)", tc.name, capturedArgs[0], tc.wantArg0, capturedArgs) + } + }) + } +} + func TestHandleDep_NumericUUID(t *testing.T) { d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { return 0, nil -- cgit v1.2.3