diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-07 09:01:46 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-07 09:01:46 +0300 |
| commit | 627485ecf12991c08340c69c999a117dfb24eebb (patch) | |
| tree | 36c374ac0781261f9417f581b81668a43a97bed5 /internal/askcli/dispatch_test.go | |
| parent | 51d278935b8c0b07faf075d1d4e45bb2a48249a2 (diff) | |
feat: reverse alias IDs for better shell tab-completionv0.28.2
Alias IDs are now stored in reversed form (e.g. id=37 → "10" instead
of "01") so that the first character varies quickly across consecutive
IDs, making shell auto-completion more effective. The counter logic is
unchanged; only the string representation is reversed via a new
reverseString helper in encodeTaskAliasID/decodeTaskAliasID.
The cache file is bumped to task-aliases-v2.json so existing mappings
are abandoned and all aliases are regenerated with the new format.
Also fix TestDispatcher_CompleteUUIDsSubcommand to use an isolated temp
dir for the alias cache, preventing flakiness from cross-test pollution.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/askcli/dispatch_test.go')
| -rw-r--r-- | internal/askcli/dispatch_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/askcli/dispatch_test.go b/internal/askcli/dispatch_test.go index ebd7273..079d156 100644 --- a/internal/askcli/dispatch_test.go +++ b/internal/askcli/dispatch_test.go @@ -57,6 +57,18 @@ func TestDispatcher_UnknownSubcommand(t *testing.T) { } func TestDispatcher_CompleteUUIDsSubcommand(t *testing.T) { + // Use a temp dir for the alias cache so this test is hermetic and does + // not depend on cache state left by other tests. + 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) |
