Initial pipelines server, CLI, TUI, and Go installation
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"pipelines/internal/pipeline"
|
||||
)
|
||||
|
||||
func TestShowcaseGraphsRender(t *testing.T) {
|
||||
for _, name := range []string{"bug-fix", "new-feature", "dashboard-screenshots", "dependency-upgrade", "incident-diagnosis"} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
source, err := os.ReadFile(filepath.Join("..", "..", "examples", name+".md"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
graph, err := pipeline.Parse(string(source))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
layout := layoutGraph(graph)
|
||||
for _, selected := range graph.Stages {
|
||||
rows := renderGraph(graph, selected.Key)
|
||||
if len(rows) != layout.height {
|
||||
t.Fatal("render height differs from layout")
|
||||
}
|
||||
for _, row := range rows {
|
||||
if lipgloss.Width(row) > layout.width {
|
||||
t.Fatal("render exceeds graph width")
|
||||
}
|
||||
}
|
||||
view := strings.Join(rows, "\n")
|
||||
for _, stage := range graph.Stages {
|
||||
if !strings.Contains(view, stage.Key) {
|
||||
t.Fatalf("missing stage %s", stage.Key)
|
||||
}
|
||||
}
|
||||
if !strings.Contains(view, "SUCCESS") || !strings.Contains(view, "FAILURE") {
|
||||
t.Fatal("missing terminal nodes")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user