29 lines
789 B
Go
29 lines
789 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"slices"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The subject the engine hears for a store settling is the event its manifest consumes: the grants part grants an account
|
|
// what its manifest consumes and nothing named in code (novox/hq ADR 0625 §4).
|
|
func TestTheSettledEventIsTheManifestsConsume(t *testing.T) {
|
|
raw, err := os.ReadFile("../../module.json")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var m struct {
|
|
Consumes []string `json:"consumes"`
|
|
}
|
|
if err := json.Unmarshal(raw, &m); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
emitter, event, _ := strings.Cut(strings.TrimPrefix(settledEvent, "mesh.mod."), ".event.")
|
|
if !slices.Contains(m.Consumes, emitter+"."+event) {
|
|
t.Errorf("the engine hears %s, its manifest consumes %v", settledEvent, m.Consumes)
|
|
}
|
|
}
|