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
65 lines
2.7 KiB
Go
65 lines
2.7 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)
|
|
}
|
|
}
|
|
|
|
// TestContributionDependencies runs this file's tests, each a subtest named as its function was (design 47 H2 §819, the test budget).
|
|
func TestContributionDependencies(t *testing.T) {
|
|
t.Run("AContributionDependsOnTheSeatThatPlacesIt", testAContributionDependsOnTheSeatThatPlacesIt)
|
|
t.Run("AHolderMeetsItsOwnContribution", testAHolderMeetsItsOwnContribution)
|
|
}
|