From dbc1029e644733843bda2536e342f7c3f8001126 Mon Sep 17 00:00:00 2001 From: KodeStar Date: Thu, 16 Jul 2026 20:30:17 +0100 Subject: [PATCH] testdata: build the apostrophe folder-book tree at test runtime The committed fixture path (AF01 - Shade's First Rule/Shade's First Rule.m4b) contains apostrophes, which golang.org/x/mod/zip prohibits in module zip file paths - so every version of this module was unfetchable by consumers (proxy or GOPROXY=direct alike), forcing dependents like audiosilo-manager and audiosilo-sidecars onto local replace directives. The apostrophes were incidental to the test (embedded-chapter expansion is the point), but they ARE worth exercising: the fixture moves to the zip-safe testdata/chaptered.m4b and the test now rebuilds the original apostrophe'd tree in a temp dir at runtime, keeping the coverage while making the module fetchable. --- internal/library/library_test.go | 25 ++++++++++++++++-- .../Shade's First Rule.m4b => chaptered.m4b} | Bin 2 files changed, 23 insertions(+), 2 deletions(-) rename testdata/{folderbook/A. F. Kay/Divine Apostasy/AF01 - Shade's First Rule/Shade's First Rule.m4b => chaptered.m4b} (100%) diff --git a/internal/library/library_test.go b/internal/library/library_test.go index 402ffd8..93024d6 100644 --- a/internal/library/library_test.go +++ b/internal/library/library_test.go @@ -174,8 +174,13 @@ func TestScannerFolderBookExpandsEmbeddedChapters(t *testing.T) { t.Cleanup(func() { db.Close() }) cat := catalog.New(db, time.Now) // A single chaptered m4b living in its own book folder - the common - // "books in their own folders" layout. - root, _ := filepath.Abs(filepath.Join("..", "..", "testdata", "folderbook")) + // "books in their own folders" layout. The tree is built at runtime (the + // apostrophes in the real-world title are prohibited inside a Go module + // zip, so a committed fixture with this path would make the whole module + // unfetchable); building it here keeps apostrophe paths exercised. + root := t.TempDir() + copyChapteredM4B(t, filepath.Join(root, + "A. F. Kay", "Divine Apostasy", "AF01 - Shade's First Rule", "Shade's First Rule.m4b")) lib, _ := cat.CreateLibrary(ctx, catalog.Library{ Name: "FolderBooks", Root: root, }) @@ -408,6 +413,22 @@ func newScanEnv(t *testing.T) (*catalog.Catalog, *Scanner, context.Context) { } // copyFixtureM4B writes a copy of a fixture audiobook to dst (creating parents). +// copyChapteredM4B copies the 3-chapter m4b fixture (Prologue / Chapter One / +// Chapter Two embedded chapter marks) to dst, creating parent directories. +func copyChapteredM4B(t *testing.T, dst string) { + t.Helper() + data, err := os.ReadFile(filepath.Join("..", "..", "testdata", "chaptered.m4b")) + if err != nil { + t.Fatal(err) + } + if err := os.MkdirAll(filepath.Dir(dst), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(dst, data, 0o644); err != nil { + t.Fatal(err) + } +} + func copyFixtureM4B(t *testing.T, dst string) { t.Helper() data, err := os.ReadFile(filepath.Join(testdataRoot(t), "Will Wight", "Cradle", "01 - Unsouled.m4b")) diff --git a/testdata/folderbook/A. F. Kay/Divine Apostasy/AF01 - Shade's First Rule/Shade's First Rule.m4b b/testdata/chaptered.m4b similarity index 100% rename from testdata/folderbook/A. F. Kay/Divine Apostasy/AF01 - Shade's First Rule/Shade's First Rule.m4b rename to testdata/chaptered.m4b