v0.3.0 99dc266

remote_attach_validation_test.go RawHistoryFolder

1package client
2
3import (
4	"context"
5	"testing"
6
7	"github.com/stretchr/testify/require"
8
9	"github.com/bnema/vev/internal/domain"
10	"github.com/bnema/vev/internal/ports"
11	portsmocks "github.com/bnema/vev/internal/ports/mocks"
12)
13
14func TestMalformedAttachRequestsNeverDial(t *testing.T) {
15	tests := []struct {
16		name    string
17		request AttachRequest
18	}{
19		{name: "missing session name", request: AttachRequest{Intent: ports.IntentAttach}},
20		{name: "unsafe session name", request: AttachRequest{Intent: ports.IntentAttach, SessionName: "bad name"}},
21		{name: "daemon-owned without remote", request: AttachRequest{Intent: ports.IntentAttach, SessionName: "main", EnvironmentPolicy: ports.EnvironmentPolicyDaemonOwned}},
22		{name: "ephemeral with navigation capability", request: AttachRequest{Intent: ports.IntentEphemeral, NavigationCapabilities: ports.NavigationCapabilityHomePicker}},
23	}
24	for _, tt := range tests {
25		t.Run(tt.name, func(t *testing.T) {
26			// No EXPECT: any Dial call fails the test.
27			dialer := portsmocks.NewMockDialer(t)
28			err := NewRunner(Dependencies{Dialer: dialer}).Run(context.Background(), tt.request)
29			require.Error(t, err)
30		})
31	}
32}
33
34func TestValidateAttachRequestRequiresDaemonOwnedEnvironmentForRemoteTarget(t *testing.T) {
35	var lifecycle domain.SessionLifecycleID
36	lifecycle[0] = 1
37	target := &domain.RemoteSessionTarget{
38		Endpoint: "arch", DisplayOrigin: "arch", LifecycleID: lifecycle,
39		SessionName: "work", LiveTabID: "tab-1",
40	}
41
42	tests := []struct {
43		name   string
44		policy ports.EnvironmentPolicy
45		wantOK bool
46	}{
47		{name: "daemon owned", policy: ports.EnvironmentPolicyDaemonOwned, wantOK: true},
48		{name: "client owned", policy: ports.EnvironmentPolicyClientOwned},
49		{name: "unknown", policy: ports.EnvironmentPolicy(99)},
50	}
51	for _, test := range tests {
52		t.Run(test.name, func(t *testing.T) {
53			err := validateAttachRequest(AttachRequest{
54				Intent: ports.IntentAttach, SessionName: target.SessionName,
55				RemoteTarget: target, EnvironmentPolicy: test.policy,
56			})
57			if test.wantOK {
58				require.NoError(t, err)
59				return
60			}
61			require.EqualError(t, err, "vev: remote attach target requires daemon-owned environment")
62		})
63	}
64}

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