The node-engine held 1,707 top-level unit tests against the budget of 500 a module. Each unit test file with two or more tests now runs them as subtests of one test named for the file, each named as its function was, in the same order: every check is kept, and the check counts 383. Files with a TestMain, a re-run of a test by its name, or the integration tag are left. Four files of this branch's earlier commits are formatted. Builds: design 47 H2 §819; H-A-349 DQ-14
39 lines
1.7 KiB
Go
39 lines
1.7 KiB
Go
package resolution
|
|
|
|
import (
|
|
"testing"
|
|
|
|
mcat "git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
func testTheMeshsPlaceForDockerIsAccepted(t *testing.T) {
|
|
// The fix #205 needed: the mesh's own directory for the module, <root>/mesh/docker.
|
|
m, err := decodeForTest([]byte(`{"module": "docker", "version": "1", "resources": [
|
|
{"id": "state", "type": "directory", "place": "mesh"},
|
|
{"id": "marker", "type": "file", "path": "${dir:state}/applied", "content": "x"}]}`))
|
|
if err != nil {
|
|
t.Fatalf("place %q is in the mesh's tree, where the mesh writes for every module: %v", "mesh", err)
|
|
}
|
|
if got := dirsFor(m, mcat.Rendering{}); got["state"] != "/var/lib/mesh/docker" {
|
|
t.Fatalf("got %v", got)
|
|
}
|
|
}
|
|
|
|
func testComposingAMachineIsNeverStoppedByOneModulesPath(t *testing.T) {
|
|
// A module registered from outside the catalogue never passes the gate. Refusing its path while a machine's
|
|
// declaration is composed would fail the whole declaration and freeze every module on that machine; the
|
|
// node-engine fails only the one resource. So composition leaves it to the engine.
|
|
m := mcat.Manifest{Module: "docker", Version: "1", Resources: []map[string]any{
|
|
{"id": "state", "type": "directory", "place": "."},
|
|
}}
|
|
if _, err := Declaration((mcat.Resolution{Node: "anchor", Modules: []mcat.Manifest{m}}), mcat.Rendering{}); err != nil {
|
|
t.Fatalf("the machine's declaration failed for one module's path: %v", err)
|
|
}
|
|
}
|
|
|
|
// TestResolvedPath runs this file's tests, each a subtest named as its function was (design 47 H2 §819, the test budget).
|
|
func TestResolvedPath(t *testing.T) {
|
|
t.Run("TheMeshsPlaceForDockerIsAccepted", testTheMeshsPlaceForDockerIsAccepted)
|
|
t.Run("ComposingAMachineIsNeverStoppedByOneModulesPath", testComposingAMachineIsNeverStoppedByOneModulesPath)
|
|
}
|