diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-23 13:35:07 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-23 13:35:07 +0200 |
| commit | bc0849e96fe41e509af4306c0953f463a7fad155 (patch) | |
| tree | ca80dd932d177bdbe9eb80cb8bffe4197d50e625 /internal/askcli/command_write_test.go | |
| parent | 462184dff3eef32f01f06634305da1355ac1bec2 (diff) | |
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:<value>" format work uniformly across annotate, start, stop,
done, modify, denotate, priority, tag, info, delete, and dep.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/askcli/command_write_test.go')
| -rw-r--r-- | internal/askcli/command_write_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/askcli/command_write_test.go b/internal/askcli/command_write_test.go index 2e494db..0b6cfb5 100644 --- a/internal/askcli/command_write_test.go +++ b/internal/askcli/command_write_test.go @@ -233,3 +233,43 @@ func TestAllWriteHandlers_PassCorrectArgs(t *testing.T) { }) } } + +// TestAllWriteHandlers_AcceptUUIDPrefix verifies that commands accept a +// "uuid:" prefixed argument (e.g. "uuid:my-uuid") and strip the prefix +// before building the taskwarrior filter, so the filter is never doubled. +func TestAllWriteHandlers_AcceptUUIDPrefix(t *testing.T) { + testCases := []struct { + subcommand string + args []string + wantArgs []string + }{ + {"denotate", []string{"denotate", "uuid:my-uuid", "text"}, []string{"uuid:my-uuid", "denotate", "text"}}, + {"modify", []string{"modify", "uuid:my-uuid", "priority:H"}, []string{"uuid:my-uuid", "modify", "priority:H"}}, + {"annotate", []string{"annotate", "uuid:my-uuid", "note"}, []string{"uuid:my-uuid", "annotate", "note"}}, + {"start", []string{"start", "uuid:my-uuid"}, []string{"uuid:my-uuid", "start"}}, + {"stop", []string{"stop", "uuid:my-uuid"}, []string{"uuid:my-uuid", "stop"}}, + {"done", []string{"done", "uuid:my-uuid"}, []string{"uuid:my-uuid", "done"}}, + {"priority", []string{"priority", "uuid:my-uuid", "H"}, []string{"uuid:my-uuid", "modify", "priority:H"}}, + {"tag", []string{"tag", "uuid:my-uuid", "+cli"}, []string{"uuid:my-uuid", "modify", "+cli"}}, + } + + for _, tc := range testCases { + t.Run(tc.subcommand, func(t *testing.T) { + var capturedArgs []string + d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { + capturedArgs = args + return 0, nil + }}) + var stdout, stderr bytes.Buffer + d.Dispatch(context.Background(), tc.args, &bytes.Buffer{}, &stdout, &stderr) + if len(capturedArgs) != len(tc.wantArgs) { + t.Fatalf("capturedArgs = %v, want %v", capturedArgs, tc.wantArgs) + } + for i, want := range tc.wantArgs { + if capturedArgs[i] != want { + t.Fatalf("capturedArgs[%d] = %q, want %q", i, capturedArgs[i], want) + } + } + }) + } +} |
