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
+45
View File
@@ -227,3 +227,48 @@ func TestASeatsVerbGainsTheArgumentsTheBinaryNames(t *testing.T) {
}
}
}
// **A stored row's build verb takes on and behind** (novox/hq ADR 0246: arguments added to a verb are
// additive): a row seeded before them described build with a repository it required, so the console
// would refuse both and a call naming neither would be refused for want of a repository. Re-seeding
// gives the row this binary's build.
func TestAStoredRowsBuildVerbTakesOnAndBehind(t *testing.T) {
inv := ForTest(t)
ctx := t.Context()
if _, err := inv.SeedSeats(ctx, catalogue.DefaultSeats()); err != nil {
t.Fatal(err)
}
old := `[{"name":"build","description":"Have the build machine build a repository.","input":{"type":"object",
"properties":{"repository":{"type":"string"},"path":{"type":"string"},"ref":{"type":"string"}},
"required":["repository"]}}]`
if _, err := inv.store.Pool().Exec(ctx, `update seat set serves = $1 where name = $2`,
[]byte(old), catalogue.ControllerSeatName); err != nil {
t.Fatal(err)
}
if _, err := inv.SeedSeats(ctx, catalogue.DefaultSeats()); err != nil {
t.Fatal(err)
}
seats, err := inv.Seats(ctx)
if err != nil {
t.Fatal(err)
}
var build catalogue.Verb
for _, s := range seats {
if s.Name == catalogue.ControllerSeatName {
for _, v := range s.Serves {
if v.Name == "build" {
build = v
}
}
}
}
props, _ := build.Input["properties"].(map[string]any)
for _, arg := range []string{"repository", "path", "ref", "on", "behind"} {
if _, has := props[arg]; !has {
t.Errorf("build in the row does not take %s: %v", arg, props)
}
}
if req, _ := build.Input["required"].([]any); len(req) != 0 {
t.Errorf("build in the row still requires %v, so on and behind alone are refused", req)
}
}