package main import ( "context" "strings" "testing" ) // With a reason, the seat passes it to the command, and a verb that only reads is not held to one. func TestARepairByHandCarriesItsReason(t *testing.T) { for _, c := range []struct { verb string args map[string]any want string }{ {"hand-act", map[string]any{"what": "restarted", "why": "hung", "cause": "proxy", "condition": "machine.a.silent"}, "hand-act record restarted --why hung --cause proxy --condition machine.a.silent"}, {"command", map[string]any{"command": "plans plan-1"}, "plans plan-1"}, } { argv, err := argvFor(c.verb, c.args) if err != nil || strings.Join(argv, " ") != c.want { t.Errorf("%s %v: %v %v, want %q", c.verb, c.args, argv, err, c.want) } } } // **A drill has its own verb** — `hand-act drill`, the seat's `drill` — and `hand-act record` refuses // the cause, so a repair cannot pass for a drill by the word it gives. func TestADrillIsRecordedThroughItsOwnVerb(t *testing.T) { err := handActCommand(context.Background(), []string{"record", "stopped searxng", "--why", "a test", "--cause", "drill"}) if err == nil || !strings.Contains(err.Error(), "hand-act drill") { t.Errorf("hand-act record --cause drill was not sent to the drill verb: %v", err) } if err := handActCommand(context.Background(), []string{"drill", "stopped searxng"}); err == nil || !strings.Contains(err.Error(), "--why") { t.Errorf("a drill without what it tests: %v", err) } if err := handActCommand(context.Background(), []string{"drill", "--why", "a test"}); err == nil || !strings.Contains(err.Error(), "hand-act drill