Merge pull request 'The build verb takes on and behind, the command's other two shapes' (#130) from feat/the-build-verb-takes-on-and-behind into main

This commit was merged in pull request #130.
This commit is contained in:
2026-10-08 00:37:14 +00:00
5 changed files with 119 additions and 10 deletions
+46
View File
@@ -36,6 +36,52 @@ func TestTheBuildToolTellsAForgePathFromAURL(t *testing.T) {
}
}
// The build tool has the command's three shapes: a repository, a base whose dependents are rebuilt
// (`--on`), or everything behind its source (`--behind`) — each asked, not waited for, one per call.
// Given neither, the command line is what it was: nothing new reaches it.
func TestTheBuildToolTakesOnAndBehind(t *testing.T) {
cases := []struct {
args map[string]any
want string
}{
{map[string]any{"on": "mesh-tools"}, "build --on mesh-tools --wait 0"},
{map[string]any{"behind": "true"}, "build --behind --wait 0"},
{map[string]any{"behind": true}, "build --behind --wait 0"},
{map[string]any{"repository": "novox/x"}, "build novox/x --wait 0 --self"},
{map[string]any{"repository": "novox/x", "behind": "false"}, "build novox/x --wait 0 --self"},
{map[string]any{"repository": "novox/x", "path": "modules/x", "ref": "main"},
"build novox/x --wait 0 --self --path modules/x --ref main"},
}
for _, c := range cases {
argv, err := argvFor("build", c.args)
if err != nil {
t.Errorf("%v: %v", c.args, err)
continue
}
if got := strings.Join(argv, " "); got != c.want {
t.Errorf("%v became %q, not %q", c.args, got, c.want)
}
}
// Naming no shape runs the bare command, which answers its usage naming all three.
if argv, err := argvFor("build", map[string]any{}); err != nil || strings.Join(argv, " ") != "build" {
t.Errorf("a build naming nothing became %v, %v", argv, err)
}
// One shape per call: a second beside it is refused, not dropped, and so is half of one.
for _, refused := range []map[string]any{
{"path": "modules/x"},
{"on": "mesh-tools", "repository": "novox/x"},
{"on": "mesh-tools", "behind": "true"},
{"behind": "true", "repository": "novox/x"},
{"behind": "true", "path": "modules/x"},
{"on": "mesh-tools", "ref": "main"},
{"behind": "yes"},
} {
if argv, err := argvFor("build", refused); err == nil {
t.Errorf("%v was accepted as %v", refused, argv)
}
}
}
// `rotate` is one verb with two shapes (ADR 0114, issue 180): a pair credential by provision, or a
// module's own secret by machine, module and name.
func TestRotateTakesAProvisionOrAnOwnSecret(t *testing.T) {