Files
pipelines/internal/pipeline/examples_test.go
T

52 lines
1.3 KiB
Go

package pipeline
import (
"os"
"path/filepath"
"testing"
"pipelines/internal/protocol"
)
func TestShowcaseDefinitions(t *testing.T) {
for _, name := range []string{"bug-fix", "new-feature", "dashboard-screenshots", "dependency-upgrade", "incident-diagnosis", "scheduled-summary", "scheduled-web-research", "anime-digest", "notification-test", "anime-today"} {
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, fork := false, false, false
for _, stage := range graph.Stages {
if stage.FallbackError {
t.Fatalf("%s should declare its error route explicitly", stage.Key)
}
targets := map[string]bool{}
for _, target := range stage.Edges {
if target == protocol.SuccessEnd {
success = true
}
if target == protocol.FailureEnd {
failure = true
}
if !protocol.IsTerminal(target) {
targets[target] = true
}
}
if len(targets) > 1 {
fork = true
}
}
if !success || !failure {
t.Fatal("showcase must have both terminal outcomes")
}
if name == "new-feature" && !fork {
t.Fatal("feature showcase must contain an exclusive route fork")
}
})
}
}