v2.2.7 aefe19e

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[registry_auth]
48enabled = true
49username = "admin"
50password = "password123"
51
52[routes]
53"app.example.com" = "nginx:latest"
54"api.example.com" = "myapi:v1"
55
56[volumes]
57auto_create = true
58prefix = "gordon"
59preserve = true
60
61[env]
62dir = "/tmp/env"
63providers = ["pass", "sops"]
64
65[logging]
66enabled = true
67level = "info"`
68
69	switch filename {
70	case "minimal.toml":
71		return `[server]
72registry_domain = "registry.example.com"
73runtime = "docker"
74
75[registry_auth]
76enabled = false`
77	case "invalid.toml":
78		return `[server
79port = 8080`
80	default:
81		return content
82	}
83}

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