The delete refused only a missing alias, so removing the default model, or an alias a saved workflow still names, succeeded and those workflows failed at their agent step. The runs module now reports the saved workflows that give an agent step a model, treating a step that names none as the default, and the delete is refused with a conflict that names them. The dashboard already shows a delete's failure inline beside the alias, so the operator sees which workflows to move first.
62 lines
1.8 KiB
Go
62 lines
1.8 KiB
Go
package runs
|
|
|
|
import "testing"
|
|
|
|
// TestWorkflowsNamingAModel guards #2097's half of the rule: the alias a
|
|
// workflow relies on is the one its agent steps name, and an agent step that
|
|
// names none relies on the default. A check that matched the wrong text would
|
|
// either refuse a delete nothing depends on, or allow one that breaks a run.
|
|
func TestWorkflowsNamingAModel(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
name string
|
|
body string
|
|
alias string
|
|
want bool
|
|
}{
|
|
{
|
|
name: "an agent step naming the alias",
|
|
body: "steps:\n - id: assess\n type: agent.run\n settings: {mission: m, model: fast}\n",
|
|
alias: "fast",
|
|
want: true,
|
|
},
|
|
{
|
|
name: "an agent step naming another alias",
|
|
body: "steps:\n - type: agent.run\n settings: {mission: m, model: careful}\n",
|
|
alias: "fast",
|
|
},
|
|
{
|
|
name: "an agent step naming no model relies on the default",
|
|
body: "steps:\n - type: agent.run\n settings: {mission: m}\n",
|
|
alias: "",
|
|
want: true,
|
|
},
|
|
{
|
|
name: "the default named outright is the same model",
|
|
body: "steps:\n - type: agent.run\n settings: {mission: m, model: default}\n",
|
|
alias: "",
|
|
want: true,
|
|
},
|
|
{
|
|
name: "a workflow with no agent step relies on no model",
|
|
body: "steps:\n - type: notify\n settings: {title: t}\n",
|
|
alias: "",
|
|
},
|
|
{
|
|
name: "an alias that only shares a prefix is another model",
|
|
body: "steps:\n - type: agent.run\n settings: {mission: m, model: faster}\n",
|
|
alias: "fast",
|
|
},
|
|
{
|
|
name: "a body that isn't a workflow names nothing",
|
|
body: "not: a workflow\n",
|
|
alias: "fast",
|
|
},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := namesModel(tc.body, tc.alias); got != tc.want {
|
|
t.Fatalf("namesModel(%q, %q) = %v, want %v", tc.body, tc.alias, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|