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
59 lines
2.4 KiB
Go
59 lines
2.4 KiB
Go
package resolution
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
mcat "git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
func TestAContributionDependsOnTheSeatThatPlacesIt(t *testing.T) {
|
|
env := mod("theme", nil, nil, nil)
|
|
env.Environment = &mcat.Environment{Variables: map[string]string{"GTK_THEME": "Adwaita:dark"}}
|
|
path := mod("toolchain", nil, nil, nil)
|
|
path.Environment = &mcat.Environment{Path: []mcat.PathEntry{{Entry: "/opt/x/bin"}}}
|
|
shell := mod("prompt", nil, nil, nil)
|
|
shell.Shell = []mcat.ShellCode{{For: "zsh", Slot: "first", Code: "true"}}
|
|
session := mod("wallpaper", nil, nil, nil)
|
|
session.Shell = []mcat.ShellCode{{For: "xinitrc", Slot: "normal", Code: "true"}}
|
|
resources := mod("bar", nil, nil, nil)
|
|
resources.Shell = []mcat.ShellCode{{For: "xresources", Slot: "normal", Code: "x: y"}}
|
|
empty := mod("nothing", nil, nil, nil)
|
|
empty.Environment = &mcat.Environment{}
|
|
|
|
cases := map[string]struct {
|
|
m mcat.Manifest
|
|
want []string
|
|
}{
|
|
"a variable": {env, []string{mcat.EnvironmentSeat}},
|
|
"a path entry": {path, []string{mcat.EnvironmentSeat}},
|
|
"shell code": {shell, []string{mcat.LoginShellSeat}},
|
|
"the session's start": {session, []string{mcat.DisplayServerSeat}},
|
|
"the session's X resources": {resources, []string{mcat.DisplayServerSeat}},
|
|
"an empty environment": {empty, nil},
|
|
}
|
|
for name, c := range cases {
|
|
got := DependsOn(nil, c.m)
|
|
if len(got) == 0 {
|
|
got = nil
|
|
}
|
|
if !reflect.DeepEqual(got, c.want) {
|
|
t.Errorf("%s depends on %v, want %v", name, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestAHolderMeetsItsOwnContribution(t *testing.T) {
|
|
// The display server's module contributes nothing to its own seat today, but the zsh module's
|
|
// environment contributions do go to another seat: a claim meets only the seat it names.
|
|
zsh := mod("zsh", nil, nil, nil, mcat.Claim{Name: mcat.LoginShellSeat})
|
|
zsh.Shell = []mcat.ShellCode{{For: "zsh", Slot: "normal", Code: "true"}}
|
|
zsh.Environment = &mcat.Environment{Variables: map[string]string{"EDITOR": "vim"}}
|
|
catalogue := map[string]mcat.Manifest{"zsh": zsh,
|
|
"node-env": mod("node-env", nil, nil, nil, mcat.Claim{Name: mcat.EnvironmentSeat})}
|
|
unheld := UnheldDependencies(catalogue, "laptop", []mcat.Manifest{zsh}, nil)
|
|
if len(unheld) != 1 || unheld[0].Seat != mcat.EnvironmentSeat {
|
|
t.Errorf("zsh alone: unheld %v, want only %s (its shell code is its own seat's)", unheld, mcat.EnvironmentSeat)
|
|
}
|
|
}
|