broker_production_test.go RawHistoryFolder

1package app
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7
8	"github.com/bnema/vev/internal/adapters/brokerconfig"
9	"github.com/bnema/vev/internal/adapters/daemonmux"
10	"github.com/bnema/vev/internal/adapters/ipc"
11	"github.com/stretchr/testify/require"
12)
13
14func TestEnsureProductionBrokerConfigCreatesPrivateEmptyBootstrapWithoutReplacingExisting(t *testing.T) {
15	configHome := t.TempDir()
16	t.Setenv("XDG_CONFIG_HOME", configHome)
17
18	require.NoError(t, ensureProductionBrokerConfig())
19	path := productionBrokerConfigPath()
20	raw, err := os.ReadFile(path)
21	require.NoError(t, err)
22	require.JSONEq(t, `{"marker":"vev.broker.offline/v1","registrations":[]}`, string(raw))
23	info, err := os.Stat(path)
24	require.NoError(t, err)
25	require.Equal(t, os.FileMode(0o600), info.Mode().Perm())
26	dirInfo, err := os.Stat(filepath.Dir(path))
27	require.NoError(t, err)
28	require.Equal(t, os.FileMode(0o700), dirInfo.Mode().Perm())
29
30	layout := productionBrokerLayout()
31	_, err = brokerconfig.LoadProduction(layout, path, "", localDaemonPolicy(), daemonmux.SocketPath(ipc.SocketDir()))
32	require.NoError(t, err)
33
34	require.NoError(t, os.WriteFile(path, []byte("operator-owned"), 0o600))
35	require.NoError(t, ensureProductionBrokerConfig())
36	raw, err = os.ReadFile(path)
37	require.NoError(t, err)
38	require.Equal(t, "operator-owned", string(raw))
39}
40
41func TestEnsureProductionBrokerConfigSupportsConcurrentFirstUse(t *testing.T) {
42	t.Setenv("XDG_CONFIG_HOME", t.TempDir())
43
44	errs := make(chan error, 16)
45	for range cap(errs) {
46		go func() { errs <- ensureProductionBrokerConfig() }()
47	}
48	for range cap(errs) {
49		require.NoError(t, <-errs)
50	}
51	raw, err := os.ReadFile(productionBrokerConfigPath())
52	require.NoError(t, err)
53	require.JSONEq(t, `{"marker":"vev.broker.offline/v1","registrations":[]}`, string(raw))
54}
55
56func TestProductionBrokerLayoutUsesDedicatedRuntimeStateAndConfig(t *testing.T) {
57	t.Setenv("XDG_RUNTIME_DIR", t.TempDir())
58	t.Setenv("XDG_STATE_HOME", t.TempDir())
59	t.Setenv("XDG_CONFIG_HOME", t.TempDir())
60
61	layout := productionBrokerLayout()
62	require.Equal(t, filepath.Join(layout.Root, "state"), layout.State)
63	require.Equal(t, filepath.Join(layout.Runtime, "spawn"), layout.Spawn)
64	require.Equal(t, "broker", filepath.Base(layout.Root))
65	require.Equal(t, "broker", filepath.Base(layout.Runtime))
66	require.Equal(t, "broker.json", filepath.Base(productionBrokerConfigPath()))
67	require.NotEqual(t, layout.Root, layout.Runtime)
68}

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