Canonical path adherence (#10)

Reviewed-on: https://gitea.westgate.pw/ShadowsOverWestgate/sow-tools/pulls/10
Co-authored-by: vickydotbat <vickydotbat@tutamail.com>
Co-committed-by: vickydotbat <vickydotbat@tutamail.com>
This commit is contained in:
2026-05-22 12:37:00 +02:00
committed by archvillainette
parent f4d92a9766
commit 835d1153f0
6 changed files with 218 additions and 128 deletions
+14 -14
View File
@@ -153,34 +153,34 @@ func TestDeployWikiDryRunReadoptsMissingMappedPost(t *testing.T) {
}
}
func TestMatchExistingNodeBBPagePrefersGeneratedPublicSlug(t *testing.T) {
func TestMatchExistingNodeBBPageIgnoresRetiredGeneratedPublicSlug(t *testing.T) {
page := wikiDeployPage{
PageID: "spells:pdk:fear",
Title: "Fear",
PublicSlug: "pdk-fear",
PublicPath: "Spells/Fear",
}
matched, ok := matchExistingNodeBBPage(page, []nodeBBWikiPage{
{TID: 31, Title: "Fear", TitleLeaf: "Fear", WikiPath: "/wiki/spells/fear"},
{TID: 32, Title: "Fear", TitleLeaf: "Fear", WikiPath: "/wiki/spells/pdk-fear"},
})
if !ok || matched.TID != 32 {
t.Fatalf("expected generated public slug to select tid 32, got %#v ok=%t", matched, ok)
if !ok || matched.TID != 31 {
t.Fatalf("expected canonical title match to select tid 31, got %#v ok=%t", matched, ok)
}
}
func TestDeploySlugifyWikiTitleMatchesGeneratedSlugPolicy(t *testing.T) {
func TestDeployCanonicalWikiSegmentMatchesGeneratedPathPolicy(t *testing.T) {
tests := map[string]string{
`Grandmaster's Battle Momentum`: "grandmasters-battle-momentum",
`Bigbys Clenched Fist`: "bigbys-clenched-fist",
`Hardiness vs. Enchantments`: "hardiness-vs-enchantments",
`Clairaudience/Clairvoyance`: "clairaudience-clairvoyance",
`Élite &amp; Noble Houses`: "elite-noble-houses",
`Alpha!@#$%^&*()[]-=_+/?.,<>` + "`" + `~|\Omega`: "alpha-omega",
`Æther Œuvre Øresund Straße Þorn Łódź Đelta`: "aether-oeuvre-oresund-strasse-thorn-lodz-delta",
`Grandmaster's Battle Momentum`: "Grandmasters_Battle_Momentum",
`Bigbys Clenched Fist`: "Bigbys_Clenched_Fist",
`Hardiness vs. Enchantments`: "Hardiness_vs_Enchantments",
`Clairaudience/Clairvoyance`: "Clairaudience_Clairvoyance",
`Élite &amp; Noble Houses`: "Elite_Noble_Houses",
`Alpha!@#$%^&*()[]-=_+/?.,<>` + "`" + `~|\Omega`: "Alpha_Omega",
`Æther Œuvre Øresund Straße Þorn Łódź Đelta`: "Aether_Oeuvre_Oresund_Strasse_Thorn_Lodz_Delta",
}
for input, want := range tests {
if got := slugifyWikiTitle(input); got != want {
t.Fatalf("slugifyWikiTitle(%q) = %q, want %q", input, got, want)
if got := canonicalWikiSegment(input); got != want {
t.Fatalf("canonicalWikiSegment(%q) = %q, want %q", input, got, want)
}
}
}