main 33a243c

registry_setup_test.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package main
4
5import (
6	"context"
7	"strings"
8	"testing"
9
10	"bnema.dev/ermite-runner/internal/actionscache"
11	"bnema.dev/ermite-runner/internal/cachesvc"
12	"bnema.dev/ermite-runner/internal/sandbox"
13)
14
15// The three size caps share one parser: a zero size in any unit turns the
16// registry proxy and the action archive cache off, and is refused for the
17// cache API, which ERMITE_RUNNER_CACHE=0 turns off. Each error names its
18// variable.
19func TestCacheSizeConfiguration(t *testing.T) {
20	t.Setenv(envCache, "1")
21	for _, tc := range []struct {
22		registry, actions, cache string
23		registryOn, archivesOn   bool
24	}{
25		{"", "", "1M", true, true},
26		{"1M", "0", "2M", true, false},
27		{"0", "1M", "1M", false, true},
28		{"0G", "0GiB", "1M", false, false},
29		{" 0M ", "", "1M", false, true},
30		{"00", "", "1M", false, true},
31		{"0GiB", "", "1M", false, true},
32		{"10M", "", "1M", true, true},
33	} {
34		t.Setenv(envRegistryMax, tc.registry)
35		t.Setenv(actionscache.EnvMax, tc.actions)
36		t.Setenv(cachesvc.EnvMax, tc.cache)
37		cfg := sandbox.Config{StateDir: t.TempDir()}
38		svc, archives, err := setupCache(context.Background(), &cfg)
39		if err != nil {
40			t.Fatalf("%+v: %v", tc, err)
41		}
42		if svc.RegistryEnabled() != tc.registryOn || (archives != nil) != tc.archivesOn {
43			t.Fatalf("%+v: registry=%v archives=%v", tc, svc.RegistryEnabled(), archives != nil)
44		}
45		_ = svc.CloseAll()
46	}
47	t.Setenv(envRegistryMax, "")
48	t.Setenv(actionscache.EnvMax, "")
49	t.Setenv(cachesvc.EnvMax, "")
50	for _, tc := range []struct{ env, value string }{
51		{envRegistryMax, "invalid"}, {envRegistryMax, "G"}, {envRegistryMax, "-1G"},
52		{actionscache.EnvMax, "x"},
53		{cachesvc.EnvMax, "0"}, {cachesvc.EnvMax, "0G"}, {cachesvc.EnvMax, "-1"},
54	} {
55		t.Run(tc.env+"="+tc.value, func(t *testing.T) {
56			t.Setenv(tc.env, tc.value)
57			cfg := sandbox.Config{StateDir: t.TempDir()}
58			svc, _, err := setupCache(context.Background(), &cfg)
59			if err == nil {
60				_ = svc.CloseAll()
61				t.Fatal("accepted")
62			}
63			if !strings.HasPrefix(err.Error(), tc.env+": ") {
64				t.Fatalf("error does not name %s: %v", tc.env, err)
65			}
66		})
67	}
68	t.Setenv(envCache, "0")
69	t.Setenv(envRegistryMax, "invalid")
70	cfg := sandbox.Config{StateDir: t.TempDir()}
71	svc, _, err := setupCache(context.Background(), &cfg)
72	if err != nil || svc != nil {
73		t.Fatalf("cache off: %v %v", svc, err)
74	}
75}

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 4

Tags 11

↑↓ moveenter openesc close