Files
pipelines/internal/cli/client_default_test.go
T
alan fc7dbb0ac0 Remove ntfy: notifications go only through the app notification stream
Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat
tool notify, auto-switch and schedule notices), the chat push outbox (its
table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*.
The app_notifications stream, subscribe/clear and kinds are unchanged.
Notification settings keep run_finished/chat_needs_you/chat_reply_finished;
ntfy_enabled is accepted and ignored and its stored row is never read.

Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to
the Pipelines apps — use the stage notify hook". The notify hook remains.

Installer: no ntfy build, accounts, config or supervisor child; manifest
gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an
old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log,
with a note in logs/install.log); uninstall cleans leftovers.

App: ntfy settings section replaced by "Notification events"; texts updated.
Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli,
author skill references updated; security review M1 marked resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:24:24 +00:00

75 lines
2.3 KiB
Go

package cli_test
import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strings"
"testing"
"time"
"git.a-wan.net/alan/pipelines/internal/cli"
"git.a-wan.net/alan/pipelines/internal/protocol"
"github.com/coder/websocket"
"github.com/coder/websocket/wsjson"
)
func TestInstalledDockerDefaultAvoidsUnconfiguredServerAndHonorsOverrides(t *testing.T) {
endpoint := func(health string) string {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
conn, err := websocket.Accept(w, r, nil)
if err != nil {
return
}
defer conn.CloseNow()
ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
defer cancel()
var request protocol.Message
if err := wsjson.Read(ctx, conn, &request); err != nil {
return
}
wsjson.Write(ctx, conn, protocol.Message{Type: protocol.Status, ID: request.ID, Status: &protocol.SystemStatus{Hostname: health}})
}))
t.Cleanup(srv.Close)
return "ws" + strings.TrimPrefix(srv.URL, "http") + "/connect"
}
docker, native := endpoint("healthy"), endpoint("not configured")
directory := t.TempDir()
t.Setenv("XDG_CONFIG_HOME", directory)
t.Setenv("PIPELINES_URL", "")
path := filepath.Join(directory, "pipelines", "client.json")
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
t.Fatal(err)
}
data, _ := json.Marshal(map[string]string{"server_url": docker})
if err := os.WriteFile(path, data, 0600); err != nil {
t.Fatal(err)
}
check := func(want string, args ...string) {
t.Helper()
var out, stderr bytes.Buffer
if err := (cli.App{Out: &out, Err: &stderr}).Run(context.Background(), args); err != nil {
t.Fatal(err, stderr.String())
}
var status protocol.SystemStatus
if json.Unmarshal(out.Bytes(), &status) != nil || status.Hostname != want {
t.Fatal("wrong server selected", out.String())
}
}
check("healthy", "status", "--json")
check("not configured", "--url", native, "status", "--json")
t.Setenv("PIPELINES_URL", native)
check("not configured", "status", "--json")
check("healthy", "status", "--url", docker, "--json")
// An explicit selector must still work even if a saved file is malformed.
if err := os.WriteFile(path, []byte("broken"), 0600); err != nil {
t.Fatal(err)
}
t.Setenv("PIPELINES_URL", "")
check("healthy", "status", "--url", docker, "--json")
}