v2.30.0-pre 7341e0e

parity_matrix_test.go RawHistoryFolder

1package cli
2
3import (
4	"go/ast"
5	"go/parser"
6	"go/token"
7	"os"
8	"strings"
9	"testing"
10)
11
12type uiAdoptionExpectation struct {
13	family    string
14	file      string
15	functions []string
16}
17
18var uiAdoptionExpectations = []uiAdoptionExpectation{
19	{
20		family:    "server",
21		file:      "serve.go",
22		functions: []string{"newStartCmd"},
23	},
24	{
25		family:    "root/server",
26		file:      "root.go",
27		functions: []string{"newVersionCmd", "runReloadRemote", "runLogsRemote", "streamLogsRemote", "showContainerLogsLocal"},
28	},
29	{
30		family:    "backups",
31		file:      "backup.go",
32		functions: []string{"newBackupListCmd", "newBackupRunCmd", "newBackupDetectCmd", "newBackupStatusCmd"},
33	},
34	{
35		family:    "images",
36		file:      "images.go",
37		functions: []string{"runImagesList", "runImagesPrune"},
38	},
39}
40
41func TestLocalParityMatrix(t *testing.T) {
42	checks := []struct {
43		file       string
44		legacyText string
45		command    string
46	}{
47		{file: "push.go", legacyText: "push requires remote mode", command: "gordon push"},
48		{file: "rollback.go", legacyText: "rollback requires remote mode", command: "gordon rollback"},
49		{file: "backup.go", legacyText: "backup commands require a configured remote target", command: "gordon backups"},
50		{file: "routes.go", legacyText: "status command requires --remote flag or GORDON_REMOTE env var", command: "gordon status"},
51		{file: "restart.go", legacyText: "local restart does not support --with-attachments; use --remote", command: "gordon restart --with-attachments"},
52	}
53
54	for _, check := range checks {
55		content, err := os.ReadFile(check.file)
56		if err != nil {
57			t.Fatalf("failed to read %s: %v", check.file, err)
58		}
59		if strings.Contains(string(content), check.legacyText) {
60			t.Fatalf("local parity gap: %s still blocks local mode (%q found in %s)", check.command, check.legacyText, check.file)
61		}
62	}
63}
64
65func TestUIAdoptionMatrixCoverage(t *testing.T) {
66	for _, expect := range uiAdoptionExpectations {
67		expect := expect
68		t.Run(expect.family, func(t *testing.T) {
69			if len(expect.functions) == 0 {
70				t.Fatalf("ui adoption matrix for %s is empty", expect.family)
71			}
72
73			fset := token.NewFileSet()
74			fileNode, err := parser.ParseFile(fset, expect.file, nil, parser.AllErrors)
75			if err != nil {
76				t.Fatalf("failed to parse %s: %v", expect.file, err)
77			}
78
79			found := make(map[string]bool, len(expect.functions))
80			ast.Inspect(fileNode, func(n ast.Node) bool {
81				fn, ok := n.(*ast.FuncDecl)
82				if !ok {
83					return true
84				}
85				found[fn.Name.Name] = true
86				return true
87			})
88
89			for _, fn := range expect.functions {
90				if !found[fn] {
91					t.Fatalf("ui adoption matrix references missing function %s in %s", fn, expect.file)
92				}
93			}
94		})
95	}
96}

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 7

Tags 106

↑↓ moveenter openesc close