Test that the shipped data loads from a Go package per module, that a bare New fails naming WithDataFS, and that a read nothing provides names the modules its reader's manifest reads

This commit is contained in:
2026-10-10 13:08:01 +02:00
committed by Lillem4n
parent bf1becbb59
commit 3368f085fd
26 changed files with 471 additions and 188 deletions
+22
View File
@@ -0,0 +1,22 @@
package misc_test
import (
"io/fs"
"testing"
"github.com/larvit/fejkdata"
"github.com/larvit/fejkdata/data/misc"
)
func TestFSLoadsByItsManifest(t *testing.T) {
if _, err := fs.Stat(misc.FS, ".fejkdata.json"); err != nil {
t.Fatalf("FS holds no manifest: %v", err)
}
f, err := fejkdata.New(fejkdata.WithDataFS(misc.FS))
if err != nil {
t.Fatalf("New(WithDataFS(FS)) = %v", err)
}
if len(f.List()) == 0 {
t.Error("List() is empty, want the module's categories")
}
}