feat(monorepo): import repo-memory runtime
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package brief
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseFile(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
repo := t.TempDir()
|
||||
path := filepath.Join(repo, "docs", "ai")
|
||||
if err := os.MkdirAll(path, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
file := filepath.Join(path, "repo-brief.md")
|
||||
content := strings.TrimSpace(`
|
||||
---
|
||||
title: Zeus Repo Brief
|
||||
repo: zeus
|
||||
---
|
||||
|
||||
# Repo Brief
|
||||
|
||||
Intro text.
|
||||
|
||||
## Module Map
|
||||
|
||||
- app/app
|
||||
- gateway
|
||||
|
||||
## Danger Zones
|
||||
|
||||
- shared libs
|
||||
`)
|
||||
if err := os.WriteFile(file, []byte(content), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
doc, err := ParseFile(repo, file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if got, want := doc.Title, "Zeus Repo Brief"; got != want {
|
||||
t.Fatalf("title = %q, want %q", got, want)
|
||||
}
|
||||
if got, want := doc.DocPath, "docs/ai/repo-brief.md"; got != want {
|
||||
t.Fatalf("doc path = %q, want %q", got, want)
|
||||
}
|
||||
if len(doc.Sections) != 3 {
|
||||
t.Fatalf("sections = %d, want 3", len(doc.Sections))
|
||||
}
|
||||
if got, want := doc.Sections[1].Heading, "Module Map"; got != want {
|
||||
t.Fatalf("section heading = %q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user