ADR 0593 §1 and §7: compose, its bus reader and runtime reader, takein, validate, the overlay generator, the composer's run and mesh-compose, and the judgement of a move leave mesh-sdk for the node-engine's internal packages, so no other module composes and a change to them rebuilds only the node-engine. The shapes others read (the composer's request and verdict, the overlay's names, compositions and answers) stay in mesh-sdk. The node's grant is now a golden file of what the grants part composes, since the composer of the bus's user list leaves mesh-sdk too. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package validate
|
|
|
|
import (
|
|
"errors"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/declaration"
|
|
)
|
|
|
|
// The SDK's validator speaks the copied parser's vocabulary version (issue 1353 AC3).
|
|
func TestVersionIsTheParsersVersion(t *testing.T) {
|
|
if Version != declaration.Version {
|
|
t.Fatalf("validate.Version = %d, declaration.Version = %d", Version, declaration.Version)
|
|
}
|
|
}
|
|
|
|
// A body of another declaration version is refused whole, by both the validator and the parser (AC3). The body is
|
|
// the shape mesh-host's validate_test.go uses for its good declaration, with the version changed.
|
|
func TestAnotherVersionIsRefusedWhole(t *testing.T) {
|
|
body := `{"declaration": 99, "resources": [{"id": "d", "type": "directory", "path": "/var/lib/x", "mode": "0755"}]}`
|
|
problems := Declaration([]byte(body))
|
|
if len(problems) == 0 {
|
|
t.Fatal("a declaration of another version was taken")
|
|
}
|
|
_, err := declaration.Parse([]byte(body))
|
|
var refused *declaration.RefusalError
|
|
if !errors.As(err, &refused) || strings.Join(refused.Problems, "\n") != strings.Join(problems, "\n") {
|
|
t.Fatalf("the parser and the validator disagree: %v / %v", err, problems)
|
|
}
|
|
}
|