v0.2.0 80c61e3

dial_test.go RawHistoryFolder

1package ipc
2
3import (
4	"context"
5	"errors"
6	"testing"
7	"time"
8
9	"github.com/bnema/vev/internal/ports"
10)
11
12type dialTestObserver struct{}
13
14func (dialTestObserver) ObserveRuntime(ports.RuntimeMark) {}
15
16func TestDialContextCanceledOrExpired(t *testing.T) {
17	tests := []struct {
18		name string
19		ctx  func() (context.Context, context.CancelFunc)
20		want error
21	}{
22		{
23			name: "canceled",
24			ctx: func() (context.Context, context.CancelFunc) {
25				ctx, cancel := context.WithCancel(context.Background())
26				cancel()
27				return ctx, func() {}
28			},
29			want: context.Canceled,
30		},
31		{
32			name: "deadline exceeded",
33			ctx: func() (context.Context, context.CancelFunc) {
34				return context.WithDeadline(context.Background(), time.Now().Add(-time.Second))
35			},
36			want: context.DeadlineExceeded,
37		},
38	}
39
40	for _, tt := range tests {
41		t.Run(tt.name, func(t *testing.T) {
42			ctx, cancel := tt.ctx()
43			defer cancel()
44
45			transport, err := DialContext(ctx, shortSocketDir(t))
46			if transport != nil {
47				t.Fatal("DialContext returned a transport for a completed context")
48			}
49			if !errors.Is(err, tt.want) {
50				t.Fatalf("DialContext error = %v, want wrapping %v", err, tt.want)
51			}
52		})
53	}
54}
55
56func TestDialContextPreservesOptions(t *testing.T) {
57	dir := shortSocketDir(t, "vev")
58	listener, err := Listen(dir)
59	if err != nil {
60		t.Fatalf("Listen: %v", err)
61	}
62	defer func() { _ = listener.Close() }()
63
64	observer := ports.NewSerializedRuntimeObserver(dialTestObserver{}, 1)
65	defer observer.Close()
66	transport, err := DialContext(context.Background(), dir, WithRuntimeObserver(observer))
67	if err != nil {
68		t.Fatalf("DialContext: %v", err)
69	}
70	defer func() { _ = transport.Close() }()
71
72	got, ok := transport.(*unixTransport)
73	if !ok {
74		t.Fatalf("DialContext transport = %T, want *unixTransport", transport)
75	}
76	if got.observer != observer {
77		t.Fatal("DialContext did not apply runtime observer option")
78	}
79}

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