summaryrefslogtreecommitdiff
path: root/integrationtests
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-23 07:41:07 +0200
committerPaul Buetow <paul@buetow.org>2026-03-23 07:41:07 +0200
commit77a38b42f47e8842e5c60673f9b25e3871cf8d8e (patch)
treee886cb0e4cd333c62f1fe9ab00661bacf719e611 /integrationtests
parent987c08b9bd86f4e6afabfb3dcb0efaf98f1ccb38 (diff)
ask add: always emit UUID, never the numeric task ID
Use rc.verbose=new-uuid so taskwarrior prints "Created task <uuid>." directly on stdout. Parse the UUID from that line instead of doing a two-step numeric-ID lookup or falling back to an export call. Removes ExtractUUIDFromOutput (which could leak numeric IDs) and fetchUUIDByNumericID (the export fallback). Integration tests now get the UUID straight from ask add output without any extra calls. Also fixes TestMain_WiresDispatcher which expected "export" first in args, but list now prepends status:pending filter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'integrationtests')
-rw-r--r--integrationtests/ask_test.go66
1 files changed, 14 insertions, 52 deletions
diff --git a/integrationtests/ask_test.go b/integrationtests/ask_test.go
index e18aa10..42825dd 100644
--- a/integrationtests/ask_test.go
+++ b/integrationtests/ask_test.go
@@ -9,7 +9,6 @@ import (
"os/exec"
"path/filepath"
"regexp"
- "strconv"
"strings"
"testing"
"time"
@@ -114,59 +113,20 @@ func runTaskWithStdin(ctx context.Context, args []string, stdin string) (stdout,
return stdout, stderr, ee.ExitCode()
}
+// createTask creates a new task via ask add and returns its UUID.
+// ask add now outputs the UUID directly, so no follow-up lookup is needed.
func createTask(ctx context.Context, desc string) (string, error) {
- stdout, _, code := runAskWithStdin(ctx, []string{"add", "+integrationtest", desc}, "yes\n")
+ stdout, stderr, code := runAsk(ctx, []string{"add", "+integrationtest", desc})
if code != 0 {
- return "", fmt.Errorf("create task failed (code %d): %s", code, stdout.String())
+ return "", fmt.Errorf("create task failed (code %d): stdout=%s stderr=%s", code, stdout.String(), stderr.String())
}
-
- taskID := extractTaskID(stdout.String())
- if taskID == "" {
- return "", fmt.Errorf("could not extract task ID from output: %s", stdout.String())
- }
-
- time.Sleep(100 * time.Millisecond)
-
- infoOut, _, _ := runTask(ctx, []string{taskID, "info"})
- uuid := extractUUIDFromTaskInfo(infoOut.String())
+ uuid := strings.TrimSpace(stdout.String())
if uuid == "" {
- return "", fmt.Errorf("could not extract UUID from task info")
+ return "", fmt.Errorf("could not extract UUID from ask add output: %s", stdout.String())
}
return uuid, nil
}
-var taskUUIDRx = regexp.MustCompile(`UUID\s+(.+)`)
-
-func extractUUIDFromTaskInfo(output string) string {
- if m := taskUUIDRx.FindStringSubmatch(output); len(m) > 1 {
- return strings.TrimSpace(m[1])
- }
- return ""
-}
-
-func extractTaskID(output string) string {
- output = strings.TrimSpace(output)
- lines := strings.Split(output, "\n")
- for _, line := range lines {
- line = strings.TrimSpace(line)
- if strings.Contains(line, "Created task") {
- fields := strings.Fields(line)
- for i, f := range fields {
- if f == "task" && i+1 < len(fields) {
- return strings.TrimSuffix(fields[i+1], ".")
- }
- }
- }
- }
- for _, line := range lines {
- line = strings.TrimSpace(line)
- if _, err := strconv.Atoi(line); err == nil {
- return line
- }
- }
- return ""
-}
-
func deleteTask(ctx context.Context, uuid string) {
runTaskWithStdin(ctx, []string{"uuid:" + uuid, "delete"}, "yes\n")
}
@@ -201,12 +161,14 @@ type taskInfo struct {
Start string
}
-var uuidFieldRx = regexp.MustCompile(`UUID:\s+(.+)`)
-var descFieldRx = regexp.MustCompile(`Description:\s+(.+)`)
-var statusFieldRx = regexp.MustCompile(`Status:\s+(.+)`)
-var priorityFieldRx = regexp.MustCompile(`Priority:\s+(.+)`)
-var tagsFieldRx = regexp.MustCompile(`Tags:\s+(.+)`)
-var startFieldRx = regexp.MustCompile(`Started:\s+(.+)`)
+var (
+ uuidFieldRx = regexp.MustCompile(`UUID:\s+(.+)`)
+ descFieldRx = regexp.MustCompile(`Description:\s+(.+)`)
+ statusFieldRx = regexp.MustCompile(`Status:\s+(.+)`)
+ priorityFieldRx = regexp.MustCompile(`Priority:\s+(.+)`)
+ tagsFieldRx = regexp.MustCompile(`Tags:\s+(.+)`)
+ startFieldRx = regexp.MustCompile(`Started:\s+(.+)`)
+)
func parseTaskInfoText(output string, uuid string) taskInfo {
ti := taskInfo{UUID: uuid}