Expand pipeline panes and select the verified Docker client endpoint
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/client"
|
||||
"git.a-wan.net/alan/pipelines/internal/tui"
|
||||
)
|
||||
|
||||
@@ -22,6 +23,26 @@ func main() {
|
||||
allow := flag.Bool("allow-tools", false, "Compatibility flag; tools follow the pipeline stages")
|
||||
paths := flag.String("write-paths", "", "Optional narrower edit scope; default is the run directory")
|
||||
flag.Parse()
|
||||
explicit := false
|
||||
flag.Visit(func(value *flag.Flag) {
|
||||
if value.Name == "url" {
|
||||
explicit = true
|
||||
}
|
||||
})
|
||||
if !explicit {
|
||||
if value := os.Getenv("PIPELINES_URL"); value != "" {
|
||||
*url = value
|
||||
} else {
|
||||
configured, err := client.ConfiguredURL()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if configured != "" {
|
||||
*url = configured
|
||||
}
|
||||
}
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
model := tui.New(ctx, *url)
|
||||
|
||||
@@ -205,6 +205,10 @@ pannable with `h/j/k/l` or arrows while the graph is focused; `c` recenters the
|
||||
selected/current stage. `P` opens the
|
||||
pinned pipeline (lowercase `p` remains an alias only on the runs list).
|
||||
|
||||
The pipeline page also gives most height to its focused graph or stage-details
|
||||
pane; Tab switches focus and resizes the two panes. Focused titles use the same
|
||||
background highlight as the run page.
|
||||
|
||||
Press `a` to select the active/latest retained OpenCode agent session and open its
|
||||
tool evidence. Session ID is available during execution; tool transcripts appear
|
||||
when persisted (currently after generation). This does not attach a live OpenCode
|
||||
|
||||
@@ -61,6 +61,29 @@ the skill. Restart an already-running TUI to load the changes. Without Go, the
|
||||
installer explicitly warns that the host client was not updated; use native
|
||||
installation when Go is available. See [Docker setup](docker.md).
|
||||
|
||||
After ntfy verification, setup also checks the published Pipelines endpoint from
|
||||
the host (when Go or a host CLI is available) and saves it in
|
||||
`$XDG_CONFIG_HOME/pipelines/client.json`, or `~/.config/pipelines/client.json`.
|
||||
Only `server_url` is updated; unrelated settings are preserved. CLI/TUI precedence
|
||||
is `--url`, then `PIPELINES_URL`, then the saved default, then localhost:8080.
|
||||
Docker defaults to port 8081, so an old native server on 8080 must not accidentally
|
||||
become the client target. Setup warns if an environment override still selects
|
||||
another address; it does not stop or delete that other server.
|
||||
|
||||
If Status says ntfy is **not configured**, check which Pipelines server the client
|
||||
is reaching before reinstalling. On the Docker server computer:
|
||||
|
||||
```sh
|
||||
docker compose port pipelines 8080
|
||||
pipelines --url ws://127.0.0.1:8081/connect status --json
|
||||
pipelines --url ws://127.0.0.1:8081/connect tui
|
||||
```
|
||||
|
||||
Use the actual mapped port instead of 8081 if customized. On a different computer,
|
||||
use the Docker host's LAN address instead of 127.0.0.1. The saved default applies
|
||||
only on the computer/user that ran the installer. Phone reception remains untested
|
||||
by these checks.
|
||||
|
||||
## Failure evidence and confirmations
|
||||
|
||||
TUI run/retry/cancel requests cannot be sent before their confirmation modal.
|
||||
|
||||
@@ -257,6 +257,23 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
_, err := fmt.Fprintln(a.Out, "Deleted draft:", pos[0])
|
||||
return err
|
||||
}
|
||||
if command != "drafts" && os.Getenv("PIPELINES_URL") == "" {
|
||||
explicit := false
|
||||
f.Visit(func(value *flag.Flag) {
|
||||
if value.Name == "url" {
|
||||
explicit = true
|
||||
}
|
||||
})
|
||||
if !explicit {
|
||||
configured, err := client.ConfiguredURL()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if configured != "" {
|
||||
o.url = configured
|
||||
}
|
||||
}
|
||||
}
|
||||
if command == "tui" {
|
||||
if len(pos) > 0 {
|
||||
return fmt.Errorf("tui takes no arguments")
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
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{Ntfy: protocol.ServiceStatus{Health: 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.Ntfy.Health != 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")
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// ConfiguredURL is a client-only default. Explicit --url and PIPELINES_URL
|
||||
// always take precedence; no server/provider configuration is changed.
|
||||
func ConfiguredURL() (string, error) {
|
||||
directory := os.Getenv("XDG_CONFIG_HOME")
|
||||
if directory == "" {
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
directory = filepath.Join(home, ".config")
|
||||
}
|
||||
path := filepath.Join(directory, "pipelines", "client.json")
|
||||
data, err := os.ReadFile(path)
|
||||
if os.IsNotExist(err) {
|
||||
return "", nil
|
||||
}
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("read client configuration %s: %w", path, err)
|
||||
}
|
||||
var config struct {
|
||||
ServerURL string `json:"server_url"`
|
||||
}
|
||||
if len(data) > 64<<10 || json.Unmarshal(data, &config) != nil {
|
||||
return "", fmt.Errorf("invalid client configuration %s; use --url to override", path)
|
||||
}
|
||||
if config.ServerURL == "" {
|
||||
return "", nil
|
||||
}
|
||||
u, err := url.Parse(config.ServerURL)
|
||||
if err != nil || (u.Scheme != "ws" && u.Scheme != "wss") || u.Hostname() == "" || u.User != nil || u.Fragment != "" {
|
||||
return "", fmt.Errorf("invalid server_url in %s; use --url to override", path)
|
||||
}
|
||||
return config.ServerURL, nil
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfiguredURLValidationAndMissingConfig(t *testing.T) {
|
||||
directory := t.TempDir()
|
||||
t.Setenv("XDG_CONFIG_HOME", directory)
|
||||
if value, err := ConfiguredURL(); err != nil || value != "" {
|
||||
t.Fatal(value, err)
|
||||
}
|
||||
path := filepath.Join(directory, "pipelines", "client.json")
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, test := range []struct {
|
||||
text string
|
||||
valid bool
|
||||
}{
|
||||
{`{"server_url":"ws://127.0.0.1:8081/connect","custom":"keep"}`, true},
|
||||
{`{"server_url":"wss://server.example/connect"}`, true},
|
||||
{`{"server_url":"http://wrong/connect"}`, false},
|
||||
{`{"server_url":"ws://secret:token@server/connect"}`, false},
|
||||
{`not JSON`, false},
|
||||
} {
|
||||
if err := os.WriteFile(path, []byte(test.text), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
value, err := ConfiguredURL()
|
||||
if (err == nil) != test.valid || (test.valid && value == "") {
|
||||
t.Fatal(test, value, err)
|
||||
}
|
||||
if data, _ := os.ReadFile(path); string(data) != test.text {
|
||||
t.Fatal("configuration mutated")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ func NtfyLines(s *protocol.SystemStatus) []string {
|
||||
lines = append(lines, "Login: "+s.NtfyUser, "Use the password set during installation.")
|
||||
}
|
||||
if s.Ntfy.Health == "not configured" {
|
||||
lines = append(lines, "On the server: rerun ./install.sh.")
|
||||
lines = append(lines, "The connected Pipelines server has no ntfy publishing configuration.", "For Docker: check docker compose port pipelines 8080.", "Connect the TUI to that port; check --url / PIPELINES_URL.", "If this is the intended server: run ./install.sh there.")
|
||||
} else if s.Ntfy.Health == "unreachable" || s.Ntfy.Health == "unhealthy" {
|
||||
lines = append(lines, "On the server: docker compose logs ntfy")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package statusview
|
||||
|
||||
import (
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -19,3 +20,12 @@ func TestOfflineStatusIncludesBothServicesAndRedactsURLCredentials(t *testing.T)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnconfiguredNtfyExplainsConnectedServerAndEndpointMismatch(t *testing.T) {
|
||||
text := strings.Join(NtfyLines(&protocol.SystemStatus{Ntfy: protocol.ServiceStatus{Health: "not configured"}}), "\n")
|
||||
for _, want := range []string{"connected Pipelines server", "docker compose port pipelines 8080", "--url / PIPELINES_URL"} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatal("missing endpoint diagnosis", want, text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,12 @@ type paneGeometry struct {
|
||||
func (m Model) pipelineGeometry(height int) paneGeometry {
|
||||
remaining := max(0, height-3)
|
||||
if remaining >= 15 {
|
||||
bottom := remaining / 2
|
||||
graph := remaining * 3 / 4
|
||||
if m.stageFocus {
|
||||
bottom = remaining - max(6, remaining/3)
|
||||
graph = remaining / 4
|
||||
}
|
||||
graph = max(6, min(remaining-8, graph))
|
||||
bottom := remaining - graph
|
||||
return paneGeometry{graphWidth: m.width, graphHeight: remaining - bottom, stageWidth: m.width, stageHeight: bottom}
|
||||
}
|
||||
if m.stageFocus {
|
||||
@@ -203,7 +205,7 @@ func graphViewport(label string, lines []string, width, height, scrollTop, pan i
|
||||
if pan+inner < graphWidth {
|
||||
label += " →"
|
||||
}
|
||||
headers := []string{bar(label, fmt.Sprintf("%d–%d / %d", min(top+1, len(lines)), end, len(lines)), inner, focused), ""}
|
||||
headers := []string{runPaneTitle(strings.TrimPrefix(label, "▸ "), fmt.Sprintf("%d–%d / %d", min(top+1, len(lines)), end, len(lines)), inner, focused), ""}
|
||||
if graphWidth > inner {
|
||||
footer = "←/→ pan · " + footer
|
||||
}
|
||||
@@ -418,7 +420,7 @@ func (m Model) stagePanel(width, height int) string {
|
||||
if m.stageFocus {
|
||||
label = "▸ " + label
|
||||
}
|
||||
headers := []string{bar(label, fmt.Sprintf("%d / %d · rows %d–%d/%d", m.stageIndex+1, len(m.detail.Graph.Stages), min(top+1, len(lines)), min(len(lines), top+rows), len(lines)), inner, m.stageFocus), m.stageTabs(inner), columns}
|
||||
headers := []string{runPaneTitle(strings.TrimPrefix(label, "▸ "), fmt.Sprintf("%d / %d · rows %d–%d/%d", m.stageIndex+1, len(m.detail.Graph.Stages), min(top+1, len(lines)), min(len(lines), top+rows), len(lines)), inner, m.stageFocus), m.stageTabs(inner), columns}
|
||||
return panel(width, height, headers, lines[top:min(len(lines), top+rows)], "n/p stage · Tab pane · j/k scroll · PgUp/Dn page", m.stageFocus)
|
||||
}
|
||||
|
||||
|
||||
@@ -129,6 +129,25 @@ func TestPanelResponsiveLayout(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPipelineTabExpandsFocusedPane(t *testing.T) {
|
||||
m := panelModel(t)
|
||||
m.width, m.height = 120, 48
|
||||
g := m.pipelineGeometry(44)
|
||||
if g.graphHeight <= g.stageHeight*2 {
|
||||
t.Fatal("pipeline graph does not occupy most height", g)
|
||||
}
|
||||
m = press(m, "tab")
|
||||
g = m.pipelineGeometry(44)
|
||||
if !m.stageFocus || g.stageHeight <= g.graphHeight*2 {
|
||||
t.Fatal("pipeline stage pane did not expand", g)
|
||||
}
|
||||
m = press(m, "tab")
|
||||
g = m.pipelineGeometry(44)
|
||||
if m.stageFocus || g.graphHeight <= g.stageHeight*2 {
|
||||
t.Fatal("pipeline graph did not re-expand", g)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStageCapabilitiesAndScrolledHeadings(t *testing.T) {
|
||||
m := panelModel(t)
|
||||
m.detail.Graph.Stages[0].Notify = &protocol.NotificationPolicy{On: []string{"failure"}, Destination: "system"}
|
||||
|
||||
+53
-2
@@ -6,6 +6,8 @@ import ipaddress
|
||||
import re
|
||||
import shutil
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -215,11 +217,60 @@ printf 'header = "Authorization: Bearer %s"\\n' "$(cat "$PIPELINES_NTFY_TOKEN_FI
|
||||
print("Phone reception is not verified by this setup check.")
|
||||
address = self.compose("port", "pipelines", "8080", capture=True).stdout.strip()
|
||||
port = address.rsplit(":", 1)[-1]
|
||||
if not port.isdigit():
|
||||
if not port.isdigit() or not 1 <= int(port) <= 65535:
|
||||
raise ValueError("Could not identify the published Pipelines port")
|
||||
print(f"Host CLI/TUI connection: pipelines --url ws://127.0.0.1:{port}/connect tui")
|
||||
endpoint = f"ws://127.0.0.1:{port}/connect"
|
||||
self.verify_host_endpoint(endpoint)
|
||||
self.configure_client(endpoint)
|
||||
print(f"Host CLI/TUI connection: pipelines --url {endpoint} tui")
|
||||
print("Install host client binaries with ./install.sh --native if needed.")
|
||||
|
||||
def verify_host_endpoint(self, endpoint):
|
||||
if shutil.which("go"):
|
||||
command = ["go", "run", "./cmd/pipelines", "--url", endpoint, "status", "--json"]
|
||||
elif shutil.which("pipelines"):
|
||||
command = [shutil.which("pipelines"), "--url", endpoint, "status", "--json"]
|
||||
else:
|
||||
print("Host-side server connection not tested: no host Go or pipelines CLI available.")
|
||||
return
|
||||
result = self.runner(command, cwd=self.directory, capture_output=True, text=True, timeout=60)
|
||||
try:
|
||||
status = json.loads(result.stdout)
|
||||
except ValueError:
|
||||
raise ValueError("Host client could not inspect the published Docker server; setup is NOT complete")
|
||||
if (result.returncode or not isinstance(status, dict)
|
||||
or not isinstance(status.get("ntfy"), dict)
|
||||
or status["ntfy"].get("health") != "healthy"):
|
||||
raise ValueError("Host client did not reach the verified ntfy-enabled Docker server; check the published port before using the TUI")
|
||||
print("Verified: host client reaches the ntfy-enabled Docker server at " + endpoint)
|
||||
|
||||
def configure_client(self, endpoint):
|
||||
root = Path(os.environ.get("XDG_CONFIG_HOME") or Path.home()/".config")
|
||||
directory = root/"pipelines"
|
||||
path = directory/"client.json"
|
||||
if path.is_symlink():
|
||||
raise ValueError("Refusing to modify symlinked client.json; use the printed --url explicitly")
|
||||
existing = json.loads(path.read_text()) if path.exists() else {}
|
||||
if not isinstance(existing, dict):
|
||||
raise ValueError("client.json must contain an object; existing configuration was not replaced")
|
||||
existing["server_url"] = endpoint
|
||||
directory.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
temporary = None
|
||||
try:
|
||||
with tempfile.NamedTemporaryFile(mode="w", dir=directory, delete=False) as file:
|
||||
temporary = Path(file.name)
|
||||
os.chmod(temporary, 0o600)
|
||||
json.dump(existing, file, indent=2)
|
||||
file.write("\n")
|
||||
os.replace(temporary, path)
|
||||
finally:
|
||||
if temporary is not None:
|
||||
temporary.unlink(missing_ok=True)
|
||||
print(f"Saved Docker client default: {endpoint} ({path}). Restart the TUI.")
|
||||
override = os.environ.get("PIPELINES_URL", "")
|
||||
if override and override != endpoint:
|
||||
print("WARNING: PIPELINES_URL overrides the saved Docker address. Use the printed --url or update that variable; otherwise the TUI may still reach a different server.")
|
||||
|
||||
def run(self, args):
|
||||
self.compose("version", capture=True)
|
||||
self.settings(args)
|
||||
|
||||
@@ -16,6 +16,41 @@ spec.loader.exec_module(setup)
|
||||
|
||||
|
||||
class DockerSetupTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(directory.cleanup)
|
||||
environment = patch.dict(os.environ, {"XDG_CONFIG_HOME": directory.name})
|
||||
environment.start()
|
||||
self.addCleanup(environment.stop)
|
||||
|
||||
def test_verified_client_default_preserves_unrelated_settings_and_warns_on_override(self):
|
||||
path = Path(os.environ["XDG_CONFIG_HOME"])/"pipelines/client.json"
|
||||
path.parent.mkdir()
|
||||
path.write_text('{"server_url":"ws://old/connect","custom":"keep"}')
|
||||
with tempfile.TemporaryDirectory() as directory, patch.dict(os.environ, {"PIPELINES_URL":"ws://old/connect"}):
|
||||
setup.Setup(directory).configure_client("ws://127.0.0.1:8081/connect")
|
||||
self.assertEqual(setup.json.loads(path.read_text()), {"server_url":"ws://127.0.0.1:8081/connect","custom":"keep"})
|
||||
self.assertEqual(path.stat().st_mode & 0o777, 0o600)
|
||||
|
||||
def test_client_config_symlink_and_malformed_content_are_not_overwritten(self):
|
||||
path = Path(os.environ["XDG_CONFIG_HOME"])/"pipelines/client.json"
|
||||
path.parent.mkdir()
|
||||
target = path.parent/"custom.json"
|
||||
target.write_text("private custom settings")
|
||||
path.symlink_to(target)
|
||||
with self.assertRaises(ValueError): setup.Setup(".").configure_client("ws://127.0.0.1:8081/connect")
|
||||
self.assertEqual(target.read_text(),"private custom settings")
|
||||
path.unlink()
|
||||
path.write_text("not JSON")
|
||||
with self.assertRaises(ValueError): setup.Setup(".").configure_client("ws://127.0.0.1:8081/connect")
|
||||
self.assertEqual(path.read_text(), "not JSON")
|
||||
|
||||
def test_host_verification_rejects_wrong_unconfigured_server(self):
|
||||
def runner(command, **kwargs):
|
||||
return subprocess.CompletedProcess(command, 0, stdout='{"ntfy":{"health":"not configured"}}', stderr="")
|
||||
with patch.object(setup.shutil,"which",return_value="/fixture/go"), self.assertRaises(ValueError):
|
||||
setup.Setup(".",runner=runner).verify_host_endpoint("ws://127.0.0.1:8081/connect")
|
||||
|
||||
def test_validation_primes_its_own_service_and_passes_model_as_argument(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root=Path(directory);(root/".env").write_text("CUSTOM=keep\n")
|
||||
@@ -231,6 +266,8 @@ fi
|
||||
out = "127.0.0.1:8081\n"
|
||||
if fail and (fail in args or (fail=="login" and "exec opencode auth login" in args[-1]) or (fail=="provider-check" and any("provider-check" in arg for arg in args))):
|
||||
code, out = 9, "private provider data/token"
|
||||
if fail == "host" and command[0] != "docker" and args[-2:] == ["status", "--json"]:
|
||||
code, out = 9, '{"ntfy":{"health":"not configured"}}'
|
||||
return subprocess.CompletedProcess(command, code, stdout=out, stderr="")
|
||||
|
||||
args = setup.arguments([] if existing else ["--ntfy-url", "http://192.168.1.20:8090",
|
||||
@@ -250,6 +287,8 @@ fi
|
||||
self.assertLess(next(i for i,c in enumerate(calls) if "token" in c), next(i for i,c in enumerate(calls) if "build" in c))
|
||||
self.assertLess(next(i for i,c in enumerate(calls) if "exec opencode auth login" in c[-1]), next(i for i,c in enumerate(calls) if "--force-recreate" in c))
|
||||
self.assertTrue(any("curl --config -" in " ".join(c) for c in calls))
|
||||
config = Path(os.environ["XDG_CONFIG_HOME"])/"pipelines/client.json"
|
||||
self.assertEqual(setup.json.loads(config.read_text())["server_url"],"ws://127.0.0.1:8081/connect")
|
||||
|
||||
def test_reinstall_preserves_configuration_tokens_and_provider_setup(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
@@ -273,7 +312,7 @@ fi
|
||||
self.assertTrue(Path(directory, "secrets/ntfy-token.txt").stat().st_size)
|
||||
|
||||
def test_status_and_publication_failures_are_not_success(self):
|
||||
for failure in ["status", "sh", "provider-check"]:
|
||||
for failure in ["status", "sh", "provider-check", "host"]:
|
||||
with tempfile.TemporaryDirectory() as directory, self.assertRaises(ValueError):
|
||||
self.exercise(directory, fail=failure)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user