main ece7682

legacy_test.go RawHistoryFolder

1package brokerstore
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7
8	"github.com/stretchr/testify/require"
9)
10
11func TestRecoveryCorruption(t *testing.T) {
12	o := options(t)
13	s, err := Open(o)
14	require.NoError(t, err)
15	require.NoError(t, s.Close())
16	require.NoError(t, os.Remove(filepath.Join(o.Dir, "state.json")))
17	raw, err := readBounded(filepath.Join(o.Dir, "recovery.json"))
18	require.NoError(t, err)
19	var r recovery
20	require.NoError(t, strict(raw, &r))
21	r.Hosts = []byte("changed")
22	// Use the production atomic writer without changing its digest metadata.
23	writer := Store{dir: o.Dir}
24	require.NoError(t, writer.write("recovery.json", r))
25	_, err = Open(o)
26	require.ErrorContains(t, err, "digest mismatch")
27}
28
29func TestDefensiveCopiesAndConcurrentAccess(t *testing.T) {
30	o := options(t)
31	s, err := Open(o)
32	require.NoError(t, err)
33	defer s.Close()
34	h, err := s.LoadHosts()
35	require.NoError(t, err)
36	h.Hosts[0].Policy.Trust = "changed"
37	snap, err := s.Load()
38	require.NoError(t, err)
39	snap.Revision = 999
40	again, err := s.Load()
41	require.NoError(t, err)
42	require.NotEqual(t, snap.Revision, again.Revision)
43	hosts, err := s.LoadHosts()
44	require.NoError(t, err)
45	require.Equal(t, "known-hosts", hosts.Hosts[0].Policy.Trust)
46	done := make(chan struct{})
47	go func() {
48		defer close(done)
49		for i := 0; i < 30; i++ {
50			_, _ = s.Load()
51			_, _ = s.LoadHosts()
52		}
53	}()
54	for i := 0; i < 30; i++ {
55		hosts, err = s.LoadHosts()
56		require.NoError(t, err)
57		require.NoError(t, s.ReplaceHosts(hosts.Revision, hosts.Hosts))
58	}
59	<-done
60}

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