Read each module's own manifest through mesh-sdk's catalogue reader (H-A-498)
The fifteen desktop modules' tools tests failed on every manifest with "json: unknown field class": a test helper copied into each module decoded module.json into its own struct, refusing unknown fields. Manifest strictness is the catalog check's alone, and the manifest's form is a contract read through mesh-sdk's catalogue package, so the copied `manifest` struct and its reader go from the fifteen desktop modules and pacman; each test reads module.json with catalogue.Decode and asserts only the module's own promises (claims, files, tools) on catalogue.Manifest. Builds: design 47 H2 H-A-498, H-A-498 addendum
This commit is contained in:
@@ -17,6 +17,8 @@ import (
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
)
|
||||
|
||||
// rootBed is a helper over a recording runner, a stand-in process table and a plan directory of its own.
|
||||
@@ -259,8 +261,16 @@ func testTheClientCarriesTheRootActsAndSaysARefusal(t *testing.T) {
|
||||
}
|
||||
|
||||
func testTheRootHelperIsRootWithNoBusAndNoSudoRule(t *testing.T) {
|
||||
m := manifest(t)
|
||||
r := m.resource(t, "root-helper")
|
||||
manifestJSON, err := os.ReadFile("../../module.json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// manifest strictness is the catalog check's (H-A-498): the SDK's reader sets an unknown field aside.
|
||||
m, err := catalogue.Decode(manifestJSON)
|
||||
if err != nil {
|
||||
t.Fatalf("module.json: %v", err)
|
||||
}
|
||||
r := resourceOf(t, m, "root-helper")
|
||||
if r["type"] != "process" || r["name"] != "pacman-root" || r["artifact"] != "tools" ||
|
||||
strings.Join(strs(r["run"]), " ") != "./"+binaryName+" root" {
|
||||
t.Fatalf("the root helper: %v", r)
|
||||
@@ -275,7 +285,7 @@ func testTheRootHelperIsRootWithNoBusAndNoSudoRule(t *testing.T) {
|
||||
if env[EnvRootSocket] != RootSocketPath || env[EnvRootPeer] != "pacman-keeper" {
|
||||
t.Errorf("the root helper's environment names its socket and the keeper's account: %v", env)
|
||||
}
|
||||
k := m.resource(t, "keeper")
|
||||
k := resourceOf(t, m, "keeper")
|
||||
kenv, _ := k["env"].(map[string]any)
|
||||
if kenv[EnvRootSocket] != RootSocketPath {
|
||||
t.Errorf("the keeper is told the helper's socket: %v", kenv)
|
||||
|
||||
Reference in New Issue
Block a user