test_wait_helpers_test.go RawHistoryFolder

1package daemon
2
3import (
4	"testing"
5	"time"
6
7	"github.com/bnema/vev/internal/protocol/wire"
8)
9
10const testWaitTimeout = 2 * time.Second
11
12func testFramesOfType(frames []wire.Envelope, name string) []wire.Envelope {
13	matched := make([]wire.Envelope, 0, len(frames))
14	for _, frame := range frames {
15		if envelopeMessageName(nil, frame.Payload) == name {
16			matched = append(matched, frame)
17		}
18	}
19	return matched
20}
21
22func awaitTestValue[T any](t *testing.T, ch <-chan T, failure string) T {
23	t.Helper()
24	timer := time.NewTimer(testWaitTimeout)
25	defer timer.Stop()
26	select {
27	case value := <-ch:
28		return value
29	case <-timer.C:
30		t.Fatal(failure)
31		var zero T
32		return zero
33	}
34}
35
36func awaitTestCompletion(t *testing.T, done <-chan struct{}, failure string) {
37	t.Helper()
38	awaitTestValue(t, done, failure)
39}
40
41func awaitCoordinatorOutput(
42	t *testing.T,
43	sends <-chan wire.Envelope,
44	timers <-chan *coordinatorMockTimer,
45	frameContext string,
46	timeoutFailure string,
47) wire.Envelope {
48	t.Helper()
49	deadline := time.NewTimer(testWaitTimeout)
50	defer deadline.Stop()
51	for {
52		select {
53		case frame := <-sends:
54			name := envelopeMessageName(t, frame.Payload)
55			if name == "RoutePosition" {
56				continue
57			}
58			if name != "Output" {
59				t.Fatalf("unexpected frame type %s %s", name, frameContext)
60			}
61			return frame
62		case timer := <-timers:
63			timer.ch <- time.Time{}
64		case <-deadline.C:
65			t.Fatal(timeoutFailure)
66			return wire.Envelope{}
67		}
68	}
69}

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