(t *testing.T)
| 51 | } |
| 52 | |
| 53 | func TestAdd_HappyPath(t *testing.T) { |
| 54 | tmpDir := t.TempDir() |
| 55 | resetAddFlags() |
| 56 | taskDir = tmpDir |
| 57 | |
| 58 | output, err := captureAddOutput(t, "My first task") |
| 59 | if err != nil { |
| 60 | t.Fatalf("unexpected error: %v", err) |
| 61 | } |
| 62 | |
| 63 | if !strings.Contains(output, "Created task 001") { |
| 64 | t.Errorf("expected 'Created task 001' in output, got: %s", output) |
| 65 | } |
| 66 | |
| 67 | // Verify file was created |
| 68 | files, _ := filepath.Glob(filepath.Join(tmpDir, "001-*.md")) |
| 69 | if len(files) != 1 { |
| 70 | t.Fatalf("expected 1 file matching 001-*.md, got %d", len(files)) |
| 71 | } |
| 72 | |
| 73 | content, _ := os.ReadFile(files[0]) |
| 74 | fileStr := string(content) |
| 75 | |
| 76 | // Check frontmatter |
| 77 | if !strings.Contains(fileStr, `id: "001"`) { |
| 78 | t.Error("expected id: \"001\" in frontmatter") |
| 79 | } |
| 80 | if !strings.Contains(fileStr, `title: "My first task"`) { |
| 81 | t.Error("expected title in frontmatter") |
| 82 | } |
| 83 | if !strings.Contains(fileStr, "status: pending") { |
| 84 | t.Error("expected status: pending in frontmatter") |
| 85 | } |
| 86 | if !strings.Contains(fileStr, "priority: medium") { |
| 87 | t.Error("expected priority: medium in frontmatter") |
| 88 | } |
| 89 | if !strings.Contains(fileStr, "dependencies: []") { |
| 90 | t.Error("expected dependencies: [] in frontmatter") |
| 91 | } |
| 92 | if !strings.Contains(fileStr, "tags: []") { |
| 93 | t.Error("expected tags: [] in frontmatter") |
| 94 | } |
| 95 | if !strings.Contains(fileStr, "created_at: ") { |
| 96 | t.Error("expected created_at date in frontmatter") |
| 97 | } |
| 98 | |
| 99 | // Check body template |
| 100 | if !strings.Contains(fileStr, "# My first task") { |
| 101 | t.Error("expected heading in body") |
| 102 | } |
| 103 | if !strings.Contains(fileStr, "## Objective") { |
| 104 | t.Error("expected Objective section in body") |
| 105 | } |
| 106 | if !strings.Contains(fileStr, "## Tasks") { |
| 107 | t.Error("expected Tasks section in body") |
| 108 | } |
| 109 | if !strings.Contains(fileStr, "- [ ] TODO") { |
| 110 | t.Error("expected TODO checkbox in body") |
nothing calls this directly
no test coverage detected