diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-08 10:17:56 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-08 10:17:56 +0300 |
| commit | 66811bb5c21fa674b19767f34ff7d27004f838b4 (patch) | |
| tree | 1535208ed3fe4ad3a0d30520d00ee1f3f015f77e /internal/askcli/dispatch_test.go | |
| parent | 385278639394e3672bce678b49e51f14ac72638c (diff) | |
fish: complete task selectors with short aliases only
Add complete-aliases subcommand that emits tab-separated alias lines without
UUID duplicates. Wire embedded Fish script (__do_task_selectors) to call
complete-aliases; keep complete-uuids unchanged for scripts and tests.
Made-with: Cursor
Diffstat (limited to 'internal/askcli/dispatch_test.go')
| -rw-r--r-- | internal/askcli/dispatch_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/askcli/dispatch_test.go b/internal/askcli/dispatch_test.go index 90c1b99..0e13788 100644 --- a/internal/askcli/dispatch_test.go +++ b/internal/askcli/dispatch_test.go @@ -90,6 +90,38 @@ func TestDispatcher_CompleteUUIDsSubcommand(t *testing.T) { } } +func TestDispatcher_CompleteAliasesSubcommand(t *testing.T) { + dir := t.TempDir() + oldRoot := taskAliasCacheRoot + oldNow := nowTaskAliasCache + taskAliasCacheRoot = func() (string, error) { return filepath.Join(dir, "hexai"), nil } + nowTaskAliasCache = func() time.Time { return time.Date(2026, 3, 27, 12, 0, 0, 0, time.UTC) } + defer func() { + taskAliasCacheRoot = oldRoot + nowTaskAliasCache = oldNow + }() + + d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) { + if strings.Join(args, " ") != "status:pending export" { + t.Fatalf("args = %v, want pending export", args) + } + _, _ = io.WriteString(stdout, `[{"uuid":"uuid-1","description":"Sample task"}]`) + return 0, nil + }}) + var stdout, stderr bytes.Buffer + code, err := d.Dispatch(context.Background(), []string{"complete-aliases"}, nil, &stdout, &stderr) + if err != nil { + t.Fatalf("complete-aliases returned error: %v", err) + } + if code != 0 { + t.Fatalf("complete-aliases code = %d, want 0", code) + } + // Fish completion uses aliases only; UUID lines are omitted. + if got := stdout.String(); got != "0\tSample task\n" { + t.Fatalf("stdout = %q, want alias-only tab-separated list", got) + } +} + func TestDispatcher_LongHelp(t *testing.T) { d := NewDispatcher(nil) var stdout bytes.Buffer @@ -323,6 +355,11 @@ func TestDispatcher_AllSubcommandsReachExecutor(t *testing.T) { wantCalls: [][]string{{"status:pending", "export"}}, }, { + name: "complete-aliases", + args: []string{"complete-aliases"}, + wantCalls: [][]string{{"status:pending", "export"}}, + }, + { name: "info", args: []string{"info", "test-uuid"}, wantCalls: [][]string{{"uuid:test-uuid", "export"}}, |
