summaryrefslogtreecommitdiff
path: root/internal/askcli/command_urgency_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-27 06:19:31 +0200
committerPaul Buetow <paul@buetow.org>2026-03-27 06:19:31 +0200
commit6b964400deb653d2c47aa8932ab5444346833b0d (patch)
treefdb9166624b91fa11cfa1e9b4a2ca3ad63bf9739 /internal/askcli/command_urgency_test.go
parentb67069c110c210b05507fca839d45b43431f5e86 (diff)
askcli: show task aliases in output (cd322ed1-882d-40e9-ab98-689acd5f161e)
Diffstat (limited to 'internal/askcli/command_urgency_test.go')
-rw-r--r--internal/askcli/command_urgency_test.go28
1 files changed, 24 insertions, 4 deletions
diff --git a/internal/askcli/command_urgency_test.go b/internal/askcli/command_urgency_test.go
index 45ec5f5..dd6262d 100644
--- a/internal/askcli/command_urgency_test.go
+++ b/internal/askcli/command_urgency_test.go
@@ -4,11 +4,31 @@ import (
"bytes"
"context"
"io"
+ "path/filepath"
"strings"
"testing"
+ "time"
)
func TestHandleUrgency_Success(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: 2,
+ Entries: []taskAliasCacheEntry{
+ {UUID: "uuid-1", Alias: "0", CreatedAt: nowTaskAliasCache()},
+ {UUID: "uuid-2", Alias: "1", CreatedAt: nowTaskAliasCache()},
+ },
+ })
+
jsonData := `[{"uuid":"uuid-2","description":"Task 2","status":"pending","priority":"M","tags":["agent"],"urgency":10.0,"depends":[]},{"uuid":"uuid-1","description":"Task 1","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) {
io.WriteString(stdout, jsonData)
@@ -26,11 +46,11 @@ func TestHandleUrgency_Success(t *testing.T) {
}
taskLine1 := lines[2]
taskLine2 := lines[3]
- if !strings.Contains(taskLine1, "uuid-1") {
- t.Fatalf("first task line should contain uuid-1 (urgency 15.0), got: %s", taskLine1)
+ if !strings.Contains(taskLine1, "0") || strings.Contains(taskLine1, "uuid-1") {
+ t.Fatalf("first task line should contain alias 0 (urgency 15.0), got: %s", taskLine1)
}
- if !strings.Contains(taskLine2, "uuid-2") {
- t.Fatalf("second task line should contain uuid-2 (urgency 10.0), got: %s", taskLine2)
+ if !strings.Contains(taskLine2, "1") || strings.Contains(taskLine2, "uuid-2") {
+ t.Fatalf("second task line should contain alias 1 (urgency 10.0), got: %s", taskLine2)
}
}