(t *testing.T)
| 83 | } |
| 84 | |
| 85 | func TestMigrateFromJSON_MissingStoryInMd(t *testing.T) { |
| 86 | tmpDir := t.TempDir() |
| 87 | |
| 88 | // prd.json has a story that doesn't exist in prd.md |
| 89 | jsonContent := `{ |
| 90 | "project": "Test", |
| 91 | "userStories": [ |
| 92 | {"id": "US-001", "title": "Exists", "passes": true, "priority": 1}, |
| 93 | {"id": "US-999", "title": "Missing", "passes": true, "priority": 2} |
| 94 | ] |
| 95 | }` |
| 96 | if err := os.WriteFile(filepath.Join(tmpDir, "prd.json"), []byte(jsonContent), 0644); err != nil { |
| 97 | t.Fatalf("failed to write: %v", err) |
| 98 | } |
| 99 | |
| 100 | mdContent := `# Test |
| 101 | |
| 102 | ### US-001: Exists |
| 103 | - [ ] A |
| 104 | ` |
| 105 | if err := os.WriteFile(filepath.Join(tmpDir, "prd.md"), []byte(mdContent), 0644); err != nil { |
| 106 | t.Fatalf("failed to write: %v", err) |
| 107 | } |
| 108 | |
| 109 | // Should not error — missing stories are skipped |
| 110 | if err := MigrateFromJSON(tmpDir); err != nil { |
| 111 | t.Fatalf("MigrateFromJSON() error = %v", err) |
| 112 | } |
| 113 | |
| 114 | // Verify the existing story was migrated |
| 115 | p, err := ParseMarkdownPRD(filepath.Join(tmpDir, "prd.md")) |
| 116 | if err != nil { |
| 117 | t.Fatalf("parse error = %v", err) |
| 118 | } |
| 119 | if !p.UserStories[0].Passes { |
| 120 | t.Error("US-001 should be passes") |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func TestMigrateFromJSON_NoJsonFile(t *testing.T) { |
| 125 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected