ca8d6f33gave power's bar item attributes its bar places by none of; ParseManifest refuses that, and at 19:13 on 2026-10-30 every node-engine refused to compose. No check of #565 parsed the manifest: that judgement was mesh-controller's `module check`, run over every manifest by the old merge gate, and since the checker moved to mesh-delivery it runs this repository's Go tests and the composition, where no test parsed a manifest whole. Quick fix: a row refusing node-bar block attributes other than bar, place and order. Thorough fix: checks/manifests parses every modules/*/module.json with mesh-sdk's ParseManifestWith against predefined.json and its templates beside it, then CatalogueProblems, IdentityProblems and DataProblems over the shelf, the functions the nodes and registration use. Chose thorough: it refuses every kind of manifest the nodes refuse, not this attribute alone. It fails at7e905a66naming power's item 2 and passes at0695ae25.
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package manifests
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Every manifest of the catalogue is one the nodes can use, and the catalogue holds together as one shelf. A row is a
|
|
// manifest written into a catalogue of its own: power's bar item as mesh-catalog ca8d6f33 gave it (issue 774) is
|
|
// refused naming the attribute, and the same item without it passes.
|
|
func TestEveryManifestIsOneTheNodesCanUse(t *testing.T) {
|
|
for _, row := range []struct {
|
|
name, attributes, refused string
|
|
}{
|
|
{name: "the bar places by bar and place", attributes: `"bar":"bottom","place":"status","order":"45"`},
|
|
{name: "an attribute the bar places by none of (ca8d6f33)",
|
|
attributes: `"bar":"bottom","place":"status","order":"45","shows":"state","state":"power.draw"`,
|
|
refused: `"shows" is none of them`},
|
|
} {
|
|
root := t.TempDir()
|
|
dir := filepath.Join(root, "modules", "bar-user")
|
|
if err := os.MkdirAll(filepath.Join(dir, "files"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
manifest := `{"module":"bar-user","version":"1","moved":true,` +
|
|
`"build":{"artifacts":[{"name":"files","kind":"archive","from":"files"}]},` +
|
|
`"items":[{"collection":"contribution:node-bar:block","attributes":{` + row.attributes + `},"template":"files/bar"}]}`
|
|
for path, body := range map[string]string{"module.json": manifest, "files/bar": "{\"shows\":\"command\"}\n"} {
|
|
if err := os.WriteFile(filepath.Join(dir, path), []byte(body), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
got, err := Problems(root)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
joined := strings.Join(got, "\n")
|
|
if (row.refused == "") != (len(got) == 0) || !strings.Contains(joined, row.refused) {
|
|
t.Errorf("%s: refused %q, want %q", row.name, joined, row.refused)
|
|
}
|
|
}
|
|
real, err := Problems(filepath.Join("..", ".."))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(real) != 0 {
|
|
t.Fatalf("the catalogue holds manifests the nodes cannot use:\n%s", strings.Join(real, "\n"))
|
|
}
|
|
}
|