package main import ( "encoding/json" "os" "slices" "testing" "git.novox.be/novox/mesh-contracts/provisioning/go/seats/meshprovisioner" "git.novox.be/novox/mesh-sdk/go/seatlist" ) // The seat mesh-provisioner, whose plans and provisions this provider reads, is named by the seat in its manifest's `reads` // (`seat:.`), and the manifest invokes the verb that says who holds it: no module is named (design 47 G A-116). func TestTheProvisionerIsTheManifests(t *testing.T) { raw, err := os.ReadFile("../../module.json") if err != nil { t.Fatal(err) } var m struct { Reads []string `json:"reads"` Invokes []string `json:"invokes"` } if err := json.Unmarshal(raw, &m); err != nil { t.Fatal(err) } for _, state := range []string{meshprovisioner.StatePlans, meshprovisioner.StateProvisions} { if want := "seat:" + meshprovisioner.Seat + "." + state; !slices.Contains(m.Reads, want) { t.Errorf("the provider reads %s, its manifest's reads are %v", want, m.Reads) } } if want := seatlist.HolderKey(); !slices.Contains(m.Invokes, want) { t.Errorf("the provider asks %s for the holder, its manifest invokes %v", want, m.Invokes) } }