summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--integrationtests/ask_test.go58
-rw-r--r--internal/askcli/command_info_add_test.go40
2 files changed, 98 insertions, 0 deletions
diff --git a/integrationtests/ask_test.go b/integrationtests/ask_test.go
index 10dcaa9..337a486 100644
--- a/integrationtests/ask_test.go
+++ b/integrationtests/ask_test.go
@@ -163,6 +163,7 @@ type taskInfo struct {
Started string
StartTime string
Priority string
+ Depends []string
Tags []string
}
@@ -174,6 +175,7 @@ var (
startedFieldRx = regexp.MustCompile(`Started:\s+(.+)`)
startTimeFieldRx = regexp.MustCompile(`Start time:\s+(.+)`)
priorityFieldRx = regexp.MustCompile(`Priority:\s+(.+)`)
+ dependsFieldRx = regexp.MustCompile(`Depends:\s+(.+)`)
tagsFieldRx = regexp.MustCompile(`Tags:\s+(.+)`)
uuidFormatRx = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)
)
@@ -201,6 +203,12 @@ func parseTaskInfoText(output string, uuid string) taskInfo {
if m := priorityFieldRx.FindStringSubmatch(output); len(m) > 1 {
ti.Priority = strings.TrimSpace(m[1])
}
+ if m := dependsFieldRx.FindStringSubmatch(output); len(m) > 1 {
+ depStr := strings.TrimSpace(m[1])
+ if depStr != "" {
+ ti.Depends = strings.Split(depStr, ", ")
+ }
+ }
if m := tagsFieldRx.FindStringSubmatch(output); len(m) > 1 {
tagStr := strings.TrimSpace(m[1])
ti.Tags = strings.Split(tagStr, ", ")
@@ -403,6 +411,56 @@ func TestInfo(t *testing.T) {
}
}
+func TestInfoShowsAllDependencies(t *testing.T) {
+ ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
+ defer cancel()
+ t.Setenv("XDG_CACHE_HOME", t.TempDir())
+
+ dependency1, err := createTask(ctx, "integration test info dependency one")
+ if err != nil {
+ t.Fatalf("failed to create first dependency task: %v", err)
+ }
+ defer deleteTask(ctx, dependency1)
+
+ dependency2, err := createTask(ctx, "integration test info dependency two")
+ if err != nil {
+ t.Fatalf("failed to create second dependency task: %v", err)
+ }
+ defer deleteTask(ctx, dependency2)
+
+ dependent, err := createTask(ctx, "integration test task for info dependencies")
+ if err != nil {
+ t.Fatalf("failed to create dependent task: %v", err)
+ }
+ defer deleteTask(ctx, dependent)
+
+ if stdout, stderr, code := runAsk(ctx, []string{"dep", "add", dependent, dependency2}); code != 0 {
+ t.Fatalf("dep add for second dependency failed with code %d: stdout=%s stderr=%s", code, stdout.String(), stderr.String())
+ }
+ if stdout, stderr, code := runAsk(ctx, []string{"dep", "add", dependent, dependency1}); code != 0 {
+ t.Fatalf("dep add for first dependency failed with code %d: stdout=%s stderr=%s", code, stdout.String(), stderr.String())
+ }
+
+ ti, ok := getTaskInfoFast(ctx, dependent)
+ if !ok {
+ t.Fatalf("info failed for task with dependencies")
+ }
+ if len(ti.Depends) != 2 {
+ t.Fatalf("info dependencies count = %d, want 2: %+v", len(ti.Depends), ti.Depends)
+ }
+
+ alias1 := mustTaskAlias(t, ctx, dependency1)
+ alias2 := mustTaskAlias(t, ctx, dependency2)
+ wantDepends := []string{
+ alias1 + " (" + dependency1 + ")",
+ alias2 + " (" + dependency2 + ")",
+ }
+ slices.Sort(wantDepends)
+ if !slices.Equal(ti.Depends, wantDepends) {
+ t.Fatalf("info dependencies = %+v, want %+v", ti.Depends, wantDepends)
+ }
+}
+
func TestAnnotate(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
diff --git a/internal/askcli/command_info_add_test.go b/internal/askcli/command_info_add_test.go
index a7a7bc2..bd95de4 100644
--- a/internal/askcli/command_info_add_test.go
+++ b/internal/askcli/command_info_add_test.go
@@ -60,6 +60,46 @@ func TestHandleInfo_Success(t *testing.T) {
}
}
+func TestHandleInfo_AssignsDependencyAliasesFromInfo(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":["dep-b","dep-a"]}]`
+ 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:") {
+ io.WriteString(stdout, jsonData)
+ }
+ return 0, nil
+ }})
+
+ var stdout, stderr bytes.Buffer
+ code, _ := d.Dispatch(context.Background(), []string{"info", "test-uuid"}, nil, &stdout, &stderr)
+ if code != 0 {
+ t.Fatalf("info code = %d, want 0", code)
+ }
+
+ output := stdout.String()
+ if !strings.Contains(output, "Depends:") ||
+ !strings.Contains(output, "(dep-a)") ||
+ !strings.Contains(output, "(dep-b)") {
+ t.Fatalf("output missing assigned dependency aliases: %s", output)
+ }
+}
+
func TestHandleInfo_AliasSelector(t *testing.T) {
dir := t.TempDir()
oldRoot := taskAliasCacheRoot