summaryrefslogtreecommitdiff
path: root/internal/askcli/command_dep_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-23 13:35:07 +0200
committerPaul Buetow <paul@buetow.org>2026-03-23 13:35:07 +0200
commitbc0849e96fe41e509af4306c0953f463a7fad155 (patch)
treeca80dd932d177bdbe9eb80cb8bffe4197d50e625 /internal/askcli/command_dep_test.go
parent462184dff3eef32f01f06634305da1355ac1bec2 (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_dep_test.go')
-rw-r--r--internal/askcli/command_dep_test.go33
1 files changed, 33 insertions, 0 deletions
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