solutions: load a catalog without a disk (LoadFSWith, LoadBigPictureFS); skip *.conflict.md
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>
This commit is contained in:
1 parent
c8a219a84b
commit
c1c0b8a116
4 files changed
+60
-6
No files matched your search
@@ -0,0 +1,27 @@
|
||||
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())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user