Before the catalog half's first views are in (a read refused, or none-yet), the keeper reads the manifest on the trunk of the holder of the seat mesh-catalog from the seat's states modules and manifests (the holder from the seat that places modules) and makes its kept data as any module's, each entry said as ever; every other module waits as A-367 says. Builds: design 47 G A-376 (G-22-lead-answers-2.md) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
46 lines
2.1 KiB
Go
46 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
|
)
|
|
|
|
// TestHolderAcceptedReadsTheHoldersManifestFromItsFirstViews is design 47 G A-376: the entry the keeper makes before the catalog
|
|
// half's first views are in is the bus state of the holder's manifest, read through `modules` (its digest) and `manifests`.
|
|
func TestHolderAcceptedReadsTheHoldersManifestFromItsFirstViews(t *testing.T) {
|
|
digest := meshcatalogclient.ManifestDigest([]byte(`{"module":"idx","bus-state":[{"name":"revisions","storage":"object-store","template":"objects","options":{"max-mib":8}}]}`))
|
|
mod := func(d string) json.RawMessage { return json.RawMessage(`{"v":1,"manifest":"` + d + `"}`) }
|
|
man := func(text string) json.RawMessage {
|
|
b, _ := json.Marshal(map[string]any{"v": 1, "module": "idx", "manifest": text})
|
|
return b
|
|
}
|
|
rows := []struct {
|
|
name string
|
|
modules, manifests map[string]json.RawMessage
|
|
err string
|
|
module string
|
|
}{
|
|
{"read", map[string]json.RawMessage{"idx": mod(digest)}, map[string]json.RawMessage{digest: man(`{"module":"idx","bus-state":[{"name":"revisions","storage":"object-store","template":"objects","options":{"max-mib":8}}]}`)}, "", "idx"},
|
|
{"no entry of the holder yet", map[string]json.RawMessage{}, nil, "holds no entry of idx", ""},
|
|
{"its manifest is not in yet", map[string]json.RawMessage{"idx": mod(digest)}, map[string]json.RawMessage{}, "holds no manifest", ""},
|
|
{"an entry that names no manifest", map[string]json.RawMessage{"idx": mod("")}, nil, "names no manifest", ""},
|
|
}
|
|
for _, row := range rows {
|
|
t.Run(row.name, func(t *testing.T) {
|
|
a, err := holderAccepted("idx", row.modules, row.manifests)
|
|
if row.err != "" {
|
|
if err == nil || !strings.Contains(err.Error(), row.err) {
|
|
t.Fatalf("err %v, want it to contain %q", err, row.err)
|
|
}
|
|
return
|
|
}
|
|
if err != nil || a.Module != row.module || len(a.BusState) != 1 || a.BusState[0].Name != "revisions" {
|
|
t.Fatalf("got %+v, %v", a, err)
|
|
}
|
|
})
|
|
}
|
|
}
|