package wing_test import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/mathiasbq/hyperguild/ingestion/internal/wing" ) func TestKnownWings_ListsWingsWithHallsAndSkipsTheRetiredLayout(t *testing.T) { dir := t.TempDir() writePage(t, dir, "wiki/homelab/facts/a.md", "x") writePage(t, dir, "wiki/tapir/decisions/b.md", "x") writePage(t, dir, "wiki/concepts/c.md", "x") // retired layout, a file directly under a legacy dir writePage(t, dir, "wiki/sources/d.md", "x") // retired layout writePage(t, dir, "wiki/entities/e.md", "x") // retired layout writePage(t, dir, "wiki/loose-note.md", "x") // a file, not a wing writePage(t, dir, "wiki/emptywing/_index.md", "x") // a dir with no hall subdirectory got, err := wing.KnownWings(dir) require.NoError(t, err) assert.Equal(t, []string{"homelab", "tapir"}, got) } func TestKnownWings_NoWikiDirIsAnError(t *testing.T) { _, err := wing.KnownWings(t.TempDir()) assert.Error(t, err, "a brain without wiki/ must not look like a brain with no wings") } // Known matches case-insensitively and the pipeline writes the lower-case name, // so a wiki directory that is not already plain lower-case would make the // pipeline create a different, new wing. It is not a candidate. func TestKnownWings_SkipsADirectoryThatIsNotAPlainWingName(t *testing.T) { dir := t.TempDir() writePage(t, dir, "wiki/Radar/facts/a.md", "x") writePage(t, dir, "wiki/has space/facts/a.md", "x") writePage(t, dir, "wiki/ok/facts/a.md", "x") got, err := wing.KnownWings(dir) require.NoError(t, err) assert.Equal(t, []string{"ok"}, got) }