LoadFSWith reads the Big Picture from its own fs.FS, so a catalog can be embedded -- the web wizard runs the engine in the browser as WebAssembly. The knowledge index leaves out wiki-sync conflict copies (*.conflict.md). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
821 B
Go
28 lines
821 B
Go
package catalog
|
|
|
|
import (
|
|
"os"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
// A catalog without a disk (embedded, or in the browser) loads the Big
|
|
// Picture from its own fs.FS and gives the same catalog as from disk.
|
|
func TestLoadFSWith(t *testing.T) {
|
|
disk, err := Load("../engine/testdata/cat")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// "/nonexistent" as root: nothing may be read from disk
|
|
emb, err := LoadFSWith(os.DirFS("../engine/testdata/cat"), "/nonexistent", os.DirFS("../engine/testdata/bp"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if emb.BigPicture == nil || len(emb.BigPicture.Products) == 0 {
|
|
t.Fatal("no Big Picture")
|
|
}
|
|
if !reflect.DeepEqual(SortedIDs(disk.BigPicture.Products), SortedIDs(emb.BigPicture.Products)) || disk.Hash() != emb.Hash() {
|
|
t.Fatalf("embedded catalog differs: %v / %v", disk.Hash(), emb.Hash())
|
|
}
|
|
}
|