65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
package workflow
|
|
|
|
import "testing"
|
|
|
|
func TestParseDefinitionResultOutputCollision(t *testing.T) {
|
|
registry := StepRegistry{AgentRunStepName: newAgentRunStage}
|
|
tests := []struct {
|
|
name string
|
|
yaml string
|
|
wantErr bool
|
|
}{
|
|
{"top-level agent.run", `id: w
|
|
repository: none
|
|
outputs: {result: {type: string}}
|
|
steps:
|
|
- id: classify
|
|
type: agent.run
|
|
settings:
|
|
mission: m
|
|
result: {type: object, properties: {verdict: {type: string}}}
|
|
`, true},
|
|
{"switch case", `id: w
|
|
repository: none
|
|
inputs: {kind: {type: string}}
|
|
outputs: {result: {type: string}}
|
|
steps:
|
|
- switch:
|
|
on: inputs.kind
|
|
cases:
|
|
review:
|
|
- id: classify
|
|
type: agent.run
|
|
settings:
|
|
mission: m
|
|
result: {type: object, properties: {verdict: {type: string}}}
|
|
`, true},
|
|
{"no step result schema", `id: w
|
|
repository: none
|
|
outputs: {result: {type: string}}
|
|
steps:
|
|
- id: classify
|
|
type: agent.run
|
|
settings: {mission: m}
|
|
`, false},
|
|
{"output under another name", `id: w
|
|
repository: none
|
|
outputs: {verdict: {type: string}}
|
|
steps:
|
|
- id: classify
|
|
type: agent.run
|
|
settings:
|
|
mission: m
|
|
result: {type: object, properties: {verdict: {type: string}}}
|
|
`, false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
_, err := ParseDefinition(tt.yaml, registry)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Fatalf("ParseDefinition err = %v, wantErr %t", err, tt.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|