v3.3.1 31f1eec

helpers.go RawHistoryFolder

1package testutils
2
3import (
4	"context"
5	"testing"
6	"time"
7
8	"github.com/spf13/afero"
9	"github.com/stretchr/testify/require"
10)
11
12// TestContext creates a test context with timeout
13func TestContext(t *testing.T) context.Context {
14	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
15	t.Cleanup(cancel)
16	return ctx
17}
18
19// CreateTempConfig creates a temporary configuration file
20func CreateTempConfig(t *testing.T, content string) afero.Fs {
21	fs := afero.NewMemMapFs()
22	err := afero.WriteFile(fs, "/config.toml", []byte(content), 0644)
23	require.NoError(t, err)
24	return fs
25}
26
27// AssertEventuallyTrue retries a condition until it's true or times out
28func AssertEventuallyTrue(t *testing.T, condition func() bool, timeout time.Duration, message string) {
29	deadline := time.Now().Add(timeout)
30	for time.Now().Before(deadline) {
31		if condition() {
32			return
33		}
34		time.Sleep(10 * time.Millisecond)
35	}
36	t.Fatalf("Condition never became true: %s", message)
37}
38
39// LoadFixtureConfig loads a configuration fixture file
40func LoadFixtureConfig(t *testing.T, filename string) string {
41	content := `[server]
42port = 8080
43registry_port = 5000
44registry_domain = "registry.example.com"
45runtime = "docker"
46
47[auth]
48enabled = true
49secrets_backend = "unsafe"
50username = "admin"
51password = "password123"
52
53[routes]
54"app.example.com" = "nginx:latest"
55"api.example.com" = "myapi:v1"
56
57[volumes]
58auto_create = true
59prefix = "gordon"
60preserve = true
61
62[logging]
63enabled = true
64level = "info"`
65
66	switch filename {
67	case "minimal.toml":
68		return `[server]
69registry_domain = "registry.example.com"
70runtime = "docker"
71
72[auth]
73enabled = false`
74	case "invalid.toml":
75		return `[server
76port = 8080`
77	default:
78		return content
79	}
80}

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