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
37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package resolution
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
mcat "git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
const barCollector = `{"module":"bars","version":"1","moved":true,
|
|
"collections":[{"name":"blocks","comment":"#"}],
|
|
"build":{"artifacts":[{"name":"files","kind":"archive","from":"files"}]},
|
|
"resources":[{"id":"conf","type":"file","path":"/etc/bars.conf","template":"files/bars"}]}`
|
|
|
|
func TestASelectorIsRefusedWhenMalformedOrNamingACollectionNotCollected(t *testing.T) {
|
|
for placeholder, want := range map[string]string{
|
|
"${collected:blocks:bar}": "", // no equals sign: a collection named blocks:bar
|
|
"${collected:blocks:bar=top,bar=bottom}": "names bar twice",
|
|
"${collected:blocks:bar=}": "is not <attribute>=<value>",
|
|
"${collected:other:bar=top}": `does not collect "other"`,
|
|
} {
|
|
raw := strings.Replace(barCollector, `"template":"files/bars"`, `"content":"`+placeholder+`"`, 1)
|
|
raw = strings.Replace(raw, `"build":{"artifacts":[{"name":"files","kind":"archive","from":"files"}]},`, "", 1)
|
|
raw = strings.Replace(raw, `"moved":true,`, "", 1)
|
|
m, err := decodeForTest([]byte(raw))
|
|
if err == nil {
|
|
_, err = Declaration((mcat.Resolution{Node: "n", Modules: []mcat.Manifest{m}}), mcat.Rendering{})
|
|
}
|
|
if want == "" {
|
|
continue
|
|
}
|
|
if err == nil || !strings.Contains(err.Error(), want) {
|
|
t.Errorf("%s: %v, want %q", placeholder, err, want)
|
|
}
|
|
}
|
|
}
|