summaryrefslogtreecommitdiff
path: root/internal/askcli/command_info_add_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/askcli/command_info_add_test.go')
-rw-r--r--internal/askcli/command_info_add_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/internal/askcli/command_info_add_test.go b/internal/askcli/command_info_add_test.go
index 9bc13df..46996f7 100644
--- a/internal/askcli/command_info_add_test.go
+++ b/internal/askcli/command_info_add_test.go
@@ -4,8 +4,10 @@ import (
"bytes"
"context"
"io"
+ "path/filepath"
"strings"
"testing"
+ "time"
)
func TestHandleInfo_Success(t *testing.T) {
@@ -34,6 +36,42 @@ func TestHandleInfo_Success(t *testing.T) {
}
}
+func TestHandleInfo_AliasSelector(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, 26, 12, 0, 0, 0, time.UTC) }
+ defer func() {
+ taskAliasCacheRoot = oldRoot
+ nowTaskAliasCache = oldNow
+ }()
+
+ writeTaskAliasCacheForTest(t, taskAliasCache{
+ NextID: 1,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "test-uuid", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
+ jsonData := `[{"uuid":"test-uuid","description":"Test task","status":"pending","priority":"H","tags":["cli"],"urgency":15.0,"depends":[]}]`
+ d := NewDispatcher(&spyRunner{runFn: func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (int, error) {
+ if len(args) > 0 && strings.HasPrefix(args[0], "uuid:test-uuid") {
+ io.WriteString(stdout, jsonData)
+ }
+ return 0, nil
+ }})
+
+ var stdout, stderr bytes.Buffer
+ code, _ := d.Dispatch(context.Background(), []string{"info", "0"}, nil, &stdout, &stderr)
+ if code != 0 {
+ t.Fatalf("info code = %d, want 0", code)
+ }
+ if !strings.Contains(stdout.String(), "test-uuid") {
+ t.Fatalf("stdout = %q, want resolved UUID", stdout.String())
+ }
+}
+
func TestHandleInfo_NumericID(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