32029cf58f
Resolved docs/install.md, internal/cli/app.go, internal/statusview and scripts/setup-native.py: no ntfy anywhere (connection, status, installer constants, troubleshooting ports), keeping the first-run next steps, the unreachable-server and tool/Docker install hints. README drops the C compiler (ntfy was its only user). The installer summary's password wording is now per run (a reinstall in the same process no longer says "you just chose"), and its test checks the URLs then the next steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
2.9 KiB
Go
89 lines
2.9 KiB
Go
package cli_test
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"errors"
|
|
"strings"
|
|
"syscall"
|
|
"testing"
|
|
|
|
"git.a-wan.net/alan/pipelines/internal/cli"
|
|
)
|
|
|
|
// A brand-new server has no pipelines, runs, drafts or skills. Human output
|
|
// says so with a next step on stderr; stdout stays empty for scripts and
|
|
// --json output carries no prose.
|
|
func TestEmptyListsExplainNextStepOnStderrOnly(t *testing.T) {
|
|
t.Setenv("PIPELINES_NTFY_URL", "")
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
_, _, url := setup(t)
|
|
invoke := func(args ...string) (string, string) {
|
|
t.Helper()
|
|
var out, stderr bytes.Buffer
|
|
if err := (cli.App{Out: &out, Err: &stderr, In: strings.NewReader("")}).Run(context.Background(), args); err != nil {
|
|
t.Fatal(args, err)
|
|
}
|
|
return out.String(), stderr.String()
|
|
}
|
|
for _, c := range []struct {
|
|
args []string
|
|
hint string
|
|
}{
|
|
{[]string{"--url", url, "list"}, "No pipelines yet. See starting points with `pipelines templates`"},
|
|
{[]string{"--url", url, "list", "--archived"}, "No archived pipelines."},
|
|
{[]string{"--url", url, "runs"}, "No runs yet. Start one with: pipelines run <pipeline>"},
|
|
{[]string{"--url", url, "drafts"}, "No drafts."},
|
|
{[]string{"skills", "list", "--url", url}, "No library skills yet."},
|
|
} {
|
|
out, hint := invoke(c.args...)
|
|
if out != "" || !strings.Contains(hint, c.hint) {
|
|
t.Fatalf("%v: stdout %q stderr %q", c.args, out, hint)
|
|
}
|
|
out, hint = invoke(append(c.args, "--json")...)
|
|
if hint != "" || strings.Contains(out, "No ") {
|
|
t.Fatalf("%v --json: stdout %q stderr %q", c.args, out, hint)
|
|
}
|
|
}
|
|
out, _ := invoke("--url", url, "stats")
|
|
if !strings.Contains(out, "0 runs") || !strings.Contains(out, "No runs yet") || strings.Contains(out, "Daily activity") {
|
|
t.Fatalf("empty stats: %q", out)
|
|
}
|
|
out, _ = invoke("--url", url, "connection")
|
|
if strings.Contains(strings.ToLower(out), "ntfy") {
|
|
t.Fatalf("connection still describes ntfy: %q", out)
|
|
}
|
|
}
|
|
|
|
func TestUnreachableServerSaysHowToStartIt(t *testing.T) {
|
|
const closed = "ws://user:secret@127.0.0.1:1/connect?token=secret"
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
t.Setenv("PIPELINES_URL", "")
|
|
for _, c := range []struct {
|
|
app cli.App
|
|
args []string
|
|
}{
|
|
{cli.App{}, []string{"--url", closed, "runs"}},
|
|
{cli.App{}, []string{"skills", "list", "--url", closed}},
|
|
} {
|
|
var out, stderr bytes.Buffer
|
|
c.app.Out, c.app.Err, c.app.In = &out, &stderr, strings.NewReader("")
|
|
err := c.app.Run(context.Background(), c.args)
|
|
if err == nil {
|
|
t.Fatal("closed port connected")
|
|
}
|
|
text := err.Error()
|
|
for _, want := range []string{"cannot reach the Pipelines server at ws://127.0.0.1:1/connect (connection refused)", "pipelines serve", "--url or set PIPELINES_URL"} {
|
|
if !strings.Contains(text, want) {
|
|
t.Fatalf("%v: missing %q in %q", c.args, want, text)
|
|
}
|
|
}
|
|
if strings.Contains(text, "secret") {
|
|
t.Fatalf("credentials exposed: %q", text)
|
|
}
|
|
if !errors.Is(err, syscall.ECONNREFUSED) {
|
|
t.Fatalf("transport error not wrapped: %v", err)
|
|
}
|
|
}
|
|
}
|