remote_host_test.go RawHistoryFolder

1package domain
2
3import (
4	"slices"
5	"testing"
6)
7
8func TestRemoteHostTargetValidation(t *testing.T) {
9	tests := []struct {
10		name    string
11		target  string
12		wantErr bool
13	}{
14		{name: "alias", target: "arch"},
15		{name: "user at host", target: "build@mule"},
16		{name: "bracketed ipv6 with port", target: "user@[2001:db8::1]:2222"},
17		{name: "empty", target: "", wantErr: true},
18		{name: "leading whitespace", target: " arch", wantErr: true},
19		{name: "trailing whitespace", target: "arch ", wantErr: true},
20		{name: "internal whitespace", target: "build @mule", wantErr: true},
21		{name: "newline", target: "arch\n", wantErr: true},
22		{name: "tab", target: "arch\t", wantErr: true},
23		{name: "control byte", target: "arch\x00", wantErr: true},
24	}
25
26	for _, tt := range tests {
27		t.Run(tt.name, func(t *testing.T) {
28			err := ValidateRemoteHostTarget(tt.target)
29			if tt.wantErr && err == nil {
30				t.Fatalf("ValidateRemoteHostTarget(%q) = nil, want error", tt.target)
31			}
32			if !tt.wantErr && err != nil {
33				t.Fatalf("ValidateRemoteHostTarget(%q) = %v, want nil", tt.target, err)
34			}
35		})
36	}
37}
38
39func TestRemoteHostUniqueTargets(t *testing.T) {
40	tests := []struct {
41		name  string
42		input []string
43		want  []string
44	}{
45		{
46			name:  "preserves first occurrence order",
47			input: []string{"arch", "build@mule", "arch", "mule"},
48			want:  []string{"arch", "build@mule", "mule"},
49		},
50		{
51			name:  "empty input",
52			input: nil,
53			want:  []string{},
54		},
55		{
56			name:  "no duplicates",
57			input: []string{"alpha", "beta"},
58			want:  []string{"alpha", "beta"},
59		},
60	}
61
62	for _, tt := range tests {
63		t.Run(tt.name, func(t *testing.T) {
64			got := UniqueRemoteHostTargets(tt.input)
65			if got == nil {
66				t.Fatalf("UniqueRemoteHostTargets(%v) = nil, want non-nil slice", tt.input)
67			}
68			if !slices.Equal(got, tt.want) {
69				t.Fatalf("UniqueRemoteHostTargets(%v) = %v, want %v", tt.input, got, tt.want)
70			}
71		})
72	}
73}

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 12

Tags 11

↑↓ moveenter openesc close