Files
core/solutions/catalog/loadfs_test.go
T

27 lines
821 B
Go
Raw Normal View History

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())
}
}