| 9 | ) |
| 10 | |
| 11 | func TestLoadPRD(t *testing.T) { |
| 12 | // Create a temp file with valid PRD markdown |
| 13 | tmpDir := t.TempDir() |
| 14 | prdPath := filepath.Join(tmpDir, "prd.md") |
| 15 | |
| 16 | validMd := `# Test Project |
| 17 | |
| 18 | A test PRD |
| 19 | |
| 20 | ### US-001: First Story |
| 21 | **Description:** Test description |
| 22 | |
| 23 | - [ ] AC1 |
| 24 | - [ ] AC2 |
| 25 | ` |
| 26 | |
| 27 | if err := os.WriteFile(prdPath, []byte(validMd), 0644); err != nil { |
| 28 | t.Fatalf("failed to write test file: %v", err) |
| 29 | } |
| 30 | |
| 31 | p, err := LoadPRD(prdPath) |
| 32 | if err != nil { |
| 33 | t.Fatalf("LoadPRD failed: %v", err) |
| 34 | } |
| 35 | |
| 36 | if p.Project != "Test Project" { |
| 37 | t.Errorf("expected project 'Test Project', got '%s'", p.Project) |
| 38 | } |
| 39 | if p.Description != "A test PRD" { |
| 40 | t.Errorf("expected description 'A test PRD', got '%s'", p.Description) |
| 41 | } |
| 42 | if len(p.UserStories) != 1 { |
| 43 | t.Errorf("expected 1 user story, got %d", len(p.UserStories)) |
| 44 | } |
| 45 | if p.UserStories[0].ID != "US-001" { |
| 46 | t.Errorf("expected story ID 'US-001', got '%s'", p.UserStories[0].ID) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | func TestLoadPRD_FileNotFound(t *testing.T) { |
| 51 | _, err := LoadPRD("/nonexistent/path/prd.md") |