Files
alan c42a19f7d3 Improve workflow UI, retain stage diffs, and add portable pipeline transfers
Make OpenCode authoring responsive and expand the managed skill references. Add conflict-aware import/export, real-provider reference workflows, and tracked V2 generation for reliable budget accounting.
2026-10-10 20:55:42 +01:00

72 lines
1.9 KiB
Go

package author
import (
"context"
"os"
"path/filepath"
"strings"
"testing"
"git.a-wan.net/alan/pipelines/internal/draft"
)
func TestNewAndEditLaunchWithoutDiscovery(t *testing.T) {
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
t.Setenv("PIPELINES_DRAFT_DIR", t.TempDir())
if _, err := InstallSkill(); err != nil {
t.Fatal(err)
}
for _, fresh := range []bool{true, false} {
d, err := draft.Create("", "starter", "ws://remote/connect", fresh, map[bool]int{true: 0, false: 3}[fresh])
if err != nil {
t.Fatal(err)
}
dir := t.TempDir()
capture := filepath.Join(dir, "calls")
program := filepath.Join(dir, "opencode")
if err = os.WriteFile(program, []byte("#!/bin/sh\nprintf '%s\\n' \"$@\" >> '"+capture+"'\n"), 0700); err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithCancel(context.Background())
cmd, err := Command(ctx, program, d, "", "pipelines --url ws://remote/connect")
if err != nil {
cancel()
t.Fatal(err)
}
if err = cmd.Run(); err != nil {
cancel()
t.Fatal(err)
}
cancel()
data, err := os.ReadFile(capture)
if err != nil {
t.Fatal(err)
}
text := string(data)
if strings.Count(text, "--prompt\n") != 1 || strings.Contains(text, "--help") || strings.Contains(text, "--session") || !strings.Contains(text, "before reading files or running commands") {
t.Fatal("launch performs discovery or delays intent", text)
}
want := "What should this pipeline do?"
if !fresh {
want = "What would you like to change in this pipeline?"
}
if !strings.Contains(text, want) {
t.Fatal(text)
}
}
}
func BenchmarkNewPipelineCommandPreparation(b *testing.B) {
b.Setenv("XDG_CONFIG_HOME", b.TempDir())
if _, err := InstallSkill(); err != nil {
b.Fatal(err)
}
d := draft.Draft{Path: "/draft/new.md", CreateOnly: true}
b.ResetTimer()
for b.Loop() {
if _, err := Command(context.Background(), "opencode", d, "", "pipelines"); err != nil {
b.Fatal(err)
}
}
}