feat(pipeline): per-wing sources, shared concepts/entities, one slug one page (#208)
With Config.Wing a source goes to wiki/<wing>/sources/ (wing/hall frontmatter); concepts and entities stay in the shared wiki/concepts and wiki/entities, so an entity cited from two wings is ONE page with both sources (the per-wing facts/ layout duplicated it). A source slug already used anywhere but its own wing's sources/ is refused (slug is the graph identity). wiki.FindSlug added. Mutation-checked: collision guard, shared inventory, per-wing source path. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func put(t *testing.T, dir, rel string) {
|
||||
t.Helper()
|
||||
full := filepath.Join(dir, rel)
|
||||
require.NoError(t, os.MkdirAll(filepath.Dir(full), 0o755))
|
||||
require.NoError(t, os.WriteFile(full, []byte("---\ntitle: x\n---\n"), 0o644))
|
||||
}
|
||||
|
||||
func TestFindSlug(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
put(t, dir, "wiki/sources/legacy-src.md")
|
||||
put(t, dir, "wiki/concepts/a-concept.md")
|
||||
put(t, dir, "wiki/entities/an-entity.md")
|
||||
put(t, dir, "wiki/homelab/failures/in-a-hall.md")
|
||||
put(t, dir, "wiki/web-clip/sources/a-clip.md")
|
||||
|
||||
tests := []struct {
|
||||
slug string
|
||||
want string
|
||||
}{
|
||||
{"legacy-src", "wiki/sources/legacy-src.md"},
|
||||
{"a-concept", "wiki/concepts/a-concept.md"},
|
||||
{"an-entity", "wiki/entities/an-entity.md"},
|
||||
{"in-a-hall", "wiki/homelab/failures/in-a-hall.md"},
|
||||
{"a-clip", "wiki/web-clip/sources/a-clip.md"},
|
||||
{"nothing-here", ""},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.slug, func(t *testing.T) {
|
||||
got, found, err := FindSlug(dir, tt.slug)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tt.want != "", found)
|
||||
assert.Equal(t, tt.want, got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindSlug_NoWikiDirIsNotAFinding(t *testing.T) {
|
||||
_, found, err := FindSlug(t.TempDir(), "x")
|
||||
require.NoError(t, err)
|
||||
assert.False(t, found)
|
||||
}
|
||||
Reference in New Issue
Block a user