dial_test.go RawHistoryFolder

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

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