First start: create the config file and open the Config view
Without a config file arr-tui refused to start. It now creates an empty one (private, with its directory) and opens the Config view. A service with neither address nor key is "not configured", which validation allows: its client returns ErrNotConfigured without a request, its indicator stays grey, it is logged once as information, and its lists say so instead of showing errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019reK4DUGYqDUjniWYJvwUW
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
|
||||
"git.stinnesbeck.com/nils/arr-tui/internal/arr"
|
||||
"git.stinnesbeck.com/nils/arr-tui/internal/config"
|
||||
"git.stinnesbeck.com/nils/arr-tui/internal/sabnzbd"
|
||||
)
|
||||
|
||||
func newTestApp(t *testing.T) *App {
|
||||
@@ -46,3 +50,34 @@ func TestQDoesNotQuit(t *testing.T) {
|
||||
t.Error("q must be passed on as an ordinary key, not taken as quit")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartsWithoutServices(t *testing.T) {
|
||||
// The config a first start creates: nothing set up.
|
||||
a := New(&config.Config{UI: config.UI{RefreshSeconds: 3}})
|
||||
if a.views[a.active].name != "Config" {
|
||||
t.Errorf("first start opens %q, want the Config view", a.views[a.active].name)
|
||||
}
|
||||
|
||||
// The clients do not try to connect without an address.
|
||||
_, err := a.radarr.SystemStatus(t.Context())
|
||||
if !errors.Is(err, arr.ErrNotConfigured) {
|
||||
t.Fatalf("radarr without address: %v", err)
|
||||
}
|
||||
if _, err := a.sab.Version(t.Context()); !errors.Is(err, sabnzbd.ErrNotConfigured) {
|
||||
t.Fatalf("sabnzbd without address: %v", err)
|
||||
}
|
||||
|
||||
// Not configured is grey, not red, and logged once as information.
|
||||
a.SetService("Radarr", "", err)
|
||||
a.SetService("Radarr", "", err)
|
||||
if txt := a.services.GetText(false); !strings.Contains(txt, "○ Radarr") {
|
||||
t.Errorf("indicator: %q", txt)
|
||||
}
|
||||
log := a.logs.root.GetText(true)
|
||||
if strings.Count(log, "Radarr is not configured") != 1 || strings.Contains(log, "unreachable") {
|
||||
t.Errorf("log: %q", log)
|
||||
}
|
||||
if !strings.Contains(a.serviceSummary(), "Radarr: not configured") {
|
||||
t.Errorf("help summary: %q", a.serviceSummary())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user