ADR 0593 §7: the composer with its refusals leaves mesh-sdk, so mesh-sdk carries no composition rule. The catalogue functions only the node-engine's composition reaches (Resolve, Resolution's Compose, Declaration, DataItems, LeftOut, Rules and the rest, the settings, placeholder and template refusals, the rendering helpers) are copied with their tests into internal/compose/resolution; a method of a mesh-sdk shape becomes a function taking it first. The composition calls its own copies, and the captured catalogue its tests read lives here now, shared by mesh-compose's tests. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
38 lines
1.4 KiB
Go
38 lines
1.4 KiB
Go
package resolution
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
mcat "git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// A module on the shelf from before ADR 0233, which writes its backup lines by hand and declares no
|
|
// data, is still backed up: its lines are placed as written, each module's under a comment naming it.
|
|
func TestHandWrittenBackupLinesOfAnOlderModuleArePlaced(t *testing.T) {
|
|
pg, err := decodeForTest([]byte(`{"module":"pg","version":"1",
|
|
"resources":[{"id":"dumps","type":"directory","path":"/srv/pg/dumps","mode":"0700"}],
|
|
"contributions":[{"seat":"node-backup","kind":"backup","content":"run pg-dump-all\npath ${dir:dumps}"}]}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
mail, err := decodeForTest([]byte(`{"module":"mail","version":"1",
|
|
"resources":[{"id":"spool","type":"directory","mode":"0700"}],
|
|
"contributions":[{"seat":"node-backup","kind":"backup","content":"path ${dir:spool}"}]}`))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
placed, _, err := seatContributions([]mcat.Manifest{pg, mail}, mcat.Manifest{}, mcat.BackupSeat+":"+"backup", mcat.Rendering{}, nil, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, want := range []string{"# pg\nrun pg-dump-all\npath /srv/pg/dumps\n", "# mail\npath /var/lib/mail/spool\n"} {
|
|
if !strings.Contains(placed, want) {
|
|
t.Errorf("placed contributions lack %q:\n%s", want, placed)
|
|
}
|
|
}
|
|
if strings.Contains(placed, "${dir:") {
|
|
t.Errorf("a directory reached the holder unfilled:\n%s", placed)
|
|
}
|
|
}
|