Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions pkg/parser/import_topological_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,48 @@
assert.Equal(t, "a-dependency.md", result.ImportedFiles[0])
assert.Equal(t, "z-parent.md", result.ImportedFiles[1])
}

func TestImportTopologicalSortStableAcrossRuns(t *testing.T) {
tempDir := testutil.TempDir(t, "import-topo-stable-*")

files := map[string]string{
"root.md": `---
imports:
- b.md
- a.md
---`,
"a.md": `---
imports:
- c.md
tools:
a-tool: {}
---`,
"b.md": `---
tools:
b-tool: {}
---`,
"c.md": `---
tools:
c-tool: {}
---`,
}

for filename, content := range files {
filePath := filepath.Join(tempDir, filename)
err := os.WriteFile(filePath, []byte(content), 0644)
require.NoError(t, err)
}

frontmatter := map[string]any{"imports": []string{"root.md"}}

var baseline []string
for i := 0; i < 5; i++ {

Check failure on line 492 in pkg/parser/import_topological_test.go

View workflow job for this annotation

GitHub Actions / lint-go

for loop can be changed to use an integer range (Go 1.22+) (intrange)
result, err := parser.ProcessImportsFromFrontmatterWithManifest(frontmatter, tempDir, nil)
require.NoError(t, err)
if i == 0 {
baseline = append([]string(nil), result.ImportedFiles...)
continue
}
assert.Equal(t, baseline, result.ImportedFiles)
}
}
Loading