diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-16 22:39:30 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-16 22:39:30 +0200 |
| commit | 971928faff0c100ef591c2d0e92e94b9f46ae71a (patch) | |
| tree | aad62242e6107a8deefa310112c88d0409535a86 /internal/config/config_test.go | |
| parent | 96b15cd512f6f38603e1e3d20afabd8c6f303079 (diff) | |
Add global average CPU line toggled with hotkey gv0.10.0
Draw a 1px red horizontal line spanning the full window width showing
the mean CPU usage across all monitored hosts. Toggled with 'g' hotkey
and persistable to ~/.loadbarsrc via 'w'.
Bump version to 0.10.0.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/config/config_test.go')
| -rw-r--r-- | internal/config/config_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/config/config_test.go b/internal/config/config_test.go index dfa499c..db0e068 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -78,6 +78,43 @@ func TestConfig_writeTo(t *testing.T) { } } +func TestConfig_showAvgLineRoundTrip(t *testing.T) { + // Write a config with showavgline=1, read it back, verify round-trip + c := Default() + c.ShowAvgLine = true + + dir := t.TempDir() + path := filepath.Join(dir, "rc") + f, err := os.Create(path) + if err != nil { + t.Fatal(err) + } + if err := c.writeTo(f); err != nil { + f.Close() + t.Fatal(err) + } + f.Close() + + data, _ := os.ReadFile(path) + if !bytes.Contains(data, []byte("showavgline=1")) { + t.Errorf("expected showavgline=1 in output, got:\n%s", data) + } + + // Read it back + c2 := Default() + f2, err := os.Open(path) + if err != nil { + t.Fatal(err) + } + defer f2.Close() + if err := c2.parseReader(f2); err != nil { + t.Fatal(err) + } + if !c2.ShowAvgLine { + t.Error("expected ShowAvgLine=true after round-trip") + } +} + func TestGetClusterHostsFromFile(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "clusters") |
