v0.3.0 99dc266

session_connection_test.go RawHistoryFolder

1package client_test
2
3import (
4	"testing"
5
6	"github.com/bnema/vev/internal/ports"
7	portsmocks "github.com/bnema/vev/internal/ports/mocks"
8	"github.com/bnema/vev/internal/usecase/client"
9	"github.com/stretchr/testify/require"
10)
11
12func TestSessionConnectionUsesOneAttachShapeForLocalAndRemoteTransports(t *testing.T) {
13	target := client.SessionTarget{Intent: ports.IntentAttach, SessionName: "work"}
14	local := portsmocks.NewMockTransport(t)
15	remote := portsmocks.NewMockTransport(t)
16
17	localConnection, err := client.NewSessionConnection(local, target)
18	require.NoError(t, err)
19	remoteConnection, err := client.NewSessionConnection(remote, target)
20	require.NoError(t, err)
21
22	require.Equal(t, localConnection.AttachRequest(), remoteConnection.AttachRequest())
23	require.Equal(t, client.AttachRequest{Intent: ports.IntentAttach, SessionName: "work"}, localConnection.AttachRequest())
24	require.Same(t, local, localConnection.Transport())
25	require.Same(t, remote, remoteConnection.Transport())
26}
27
28func TestSessionTargetValidation(t *testing.T) {
29	tests := []struct {
30		name      string
31		target    client.SessionTarget
32		wantErr   bool
33		wantErrIs error
34	}{
35		{name: "ephemeral", target: client.SessionTarget{Intent: ports.IntentEphemeral}},
36		{name: "named ephemeral", target: client.SessionTarget{Intent: ports.IntentEphemeral, SessionName: "work"}, wantErr: true, wantErrIs: client.ErrEphemeralSessionName},
37		{name: "new", target: client.SessionTarget{Intent: ports.IntentNew, SessionName: "work"}},
38		{name: "attach", target: client.SessionTarget{Intent: ports.IntentAttach, SessionName: "work"}},
39		{name: "resume", target: client.SessionTarget{Intent: ports.IntentResume, SessionName: "work"}},
40		{name: "missing named session", target: client.SessionTarget{Intent: ports.IntentAttach}, wantErr: true},
41		{name: "unsafe session", target: client.SessionTarget{Intent: ports.IntentAttach, SessionName: "my work"}, wantErr: true},
42		{name: "unknown intent", target: client.SessionTarget{Intent: 99, SessionName: "work"}, wantErr: true},
43	}
44	for _, tt := range tests {
45		t.Run(tt.name, func(t *testing.T) {
46			transport := portsmocks.NewMockTransport(t)
47			_, err := client.NewSessionConnection(transport, tt.target)
48			if tt.wantErr {
49				require.Error(t, err)
50				if tt.wantErrIs != nil {
51					require.ErrorIs(t, err, tt.wantErrIs)
52				}
53				return
54			}
55			require.NoError(t, err)
56		})
57	}
58}
59
60func TestSessionConnectionRequiresTransport(t *testing.T) {
61	_, err := client.NewSessionConnection(nil, client.SessionTarget{Intent: ports.IntentEphemeral})
62	require.Error(t, err)
63}

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