v0.3.10 471dc8c

reload_ext_test.go RawHistoryFolder

1package modes
2
3import (
4	"errors"
5	"strings"
6	"testing"
7
8	"github.com/patriceckhart/zot/packages/agent/extensions"
9)
10
11func TestFormatReloadStatusIncludesErrorDetails(t *testing.T) {
12	msg, failed := formatReloadStatus(extensions.ReloadStats{
13		Stopped: 2,
14		Loaded:  1,
15		Ready:   1,
16		Errors: []error{
17			errors.New("broken manifest"),
18			errors.New("spawn worker: executable not found"),
19		},
20	})
21	if !failed {
22		t.Fatal("reload with errors was not marked failed")
23	}
24	for _, want := range []string{
25		"2 stopped, 1 loaded (1 ready)",
26		"2 error(s)",
27		"broken manifest",
28		"spawn worker: executable not found",
29	} {
30		if !strings.Contains(msg, want) {
31			t.Fatalf("reload status missing %q: %s", want, msg)
32		}
33	}
34}
35
36func TestFormatReloadStatusSuccess(t *testing.T) {
37	msg, failed := formatReloadStatus(extensions.ReloadStats{Stopped: 2, Loaded: 3, Ready: 3})
38	if failed {
39		t.Fatal("successful reload was marked failed")
40	}
41	if want := "reloaded: 2 stopped, 3 loaded (3 ready)"; msg != want {
42		t.Fatalf("reload status = %q, want %q", msg, want)
43	}
44}
45
46func TestSetReloadStatusUsesErrorChannelForFailures(t *testing.T) {
47	i := &Interactive{}
48	i.setReloadStatus("broken extension", true)
49	if i.statusErr != "broken extension" || i.statusOK != "" {
50		t.Fatalf("failed reload status used wrong channel: err=%q ok=%q", i.statusErr, i.statusOK)
51	}
52	i.setReloadStatus("reload complete", false)
53	if i.statusOK != "reload complete" || i.statusErr != "" {
54		t.Fatalf("successful reload status used wrong channel: err=%q ok=%q", i.statusErr, i.statusOK)
55	}
56}
57
58func TestClearReloadStatusDoesNotClearNewerStatus(t *testing.T) {
59	i := &Interactive{statusErr: "newer error", statusOK: "newer success"}
60	if i.clearReloadStatus(0, "old error", true) {
61		t.Fatal("stale error dismissal reported a clear")
62	}
63	if i.clearReloadStatus(0, "old success", false) {
64		t.Fatal("stale success dismissal reported a clear")
65	}
66	if i.statusErr != "newer error" || i.statusOK != "newer success" {
67		t.Fatalf("stale dismissal changed status: err=%q ok=%q", i.statusErr, i.statusOK)
68	}
69
70	if !i.clearReloadStatus(0, "newer error", true) || i.statusErr != "" {
71		t.Fatalf("matching error status was not cleared: %q", i.statusErr)
72	}
73	if !i.clearReloadStatus(0, "newer success", false) || i.statusOK != "" {
74		t.Fatalf("matching success status was not cleared: %q", i.statusOK)
75	}
76
77	first := i.setReloadStatus("same result", false)
78	second := i.setReloadStatus("same result", false)
79	if first == second {
80		t.Fatal("reload status generation did not advance")
81	}
82	if i.clearReloadStatus(first, "same result", false) {
83		t.Fatal("older identical reload status cleared the newer result")
84	}
85}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close