Sends reads a claim of a seat whose definition has a verb or an event, or an event of its own; AsksOf reads an entry's bus-state asks and claims. The follower's branch and the wiring wait on the design's answer. Builds: design 47 G §344, §433 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
29 lines
970 B
Go
29 lines
970 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
catalog "git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
|
)
|
|
|
|
func TestAsksOf(t *testing.T) {
|
|
m := map[string]any{"module": "m", "claims": []any{map[string]any{"name": "seat-a"}}, "emits": []any{"done"}}
|
|
a, err := AsksOf(catalog.CatalogEntry{Module: "m", Verdict: "accepted", Manifest: m})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(a.Claims) != 1 || a.Claims[0] != "seat-a" || !a.EmitsOwn || a.Accepted.Module != "m" || a.Accepted.Digest == "" {
|
|
t.Errorf("read %+v", a)
|
|
}
|
|
b, _ := AsksOf(catalog.CatalogEntry{Module: "m", Manifest: map[string]any{"module": "m"}})
|
|
if b.EmitsOwn || len(b.Claims) != 0 {
|
|
t.Errorf("an entry with neither: %+v", b)
|
|
}
|
|
if b.Accepted.Digest != a.Accepted.Digest {
|
|
t.Errorf("the digest is of the bus-state asked alone: %s vs %s", b.Accepted.Digest, a.Accepted.Digest)
|
|
}
|
|
if _, err := AsksOf(catalog.CatalogEntry{}); err == nil {
|
|
t.Error("an entry with no module was read")
|
|
}
|
|
}
|