Files
pipelines/internal/pipeline/examples_test.go
T

49 lines
1.2 KiB
Go

package pipeline
import (
"os"
"path/filepath"
"strings"
"testing"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
func TestShowcaseDefinitions(t *testing.T) {
for _, name := range []string{"task", "summary", "review", "research", "three-stage"} {
t.Run(name, func(t *testing.T) {
source, err := os.ReadFile(filepath.Join("..", "..", "examples", name+".md"))
if err != nil {
t.Fatal(err)
}
graph, err := Parse(string(source))
if err != nil {
t.Fatal(err)
}
success, failure := false, false
for _, stage := range graph.Stages {
if stage.FallbackError {
t.Fatalf("%s should declare its error route explicitly", stage.Key)
}
if strings.TrimSpace(stage.Output) == "" || strings.TrimSpace(stage.Prompt) == "" {
t.Fatalf("%s stage %s needs a nonempty output and prompt", name, stage.Key)
}
for _, target := range stage.Edges {
if target == protocol.SuccessEnd {
success = true
}
if target == protocol.FailureEnd {
failure = true
}
}
}
if !success || !failure {
t.Fatal("showcase must have both terminal outcomes")
}
if graph.Settings != nil {
t.Fatalf("%s starters must stay manual-only", name)
}
})
}
}