v0.9.0 e5e4ded

route_retired_test.go RawHistoryFolder

1package sessionwire
2
3import (
4	"testing"
5
6	"github.com/bnema/vev/internal/domain"
7	"github.com/bnema/vev/internal/protocol"
8	"github.com/bnema/vev/internal/protocol/wire"
9	"github.com/stretchr/testify/require"
10)
11
12func TestRouteRetiredServerMessage(t *testing.T) {
13	message := protocol.RouteRetired{Ref: protocol.RouteRef{Key: 1, Generation: 2}, Target: protocol.ExactSessionTarget{LifecycleID: domain.SessionLifecycleID{3}, SessionName: "work"}}
14	for _, value := range []protocol.ServerMessage{message, &message} {
15		raw, err := EncodeServerMessage(value)
16		require.NoError(t, err)
17		decoded, err := DecodeServerEnvelope(raw)
18		require.NoError(t, err)
19		require.Equal(t, message, decoded)
20		_, err = DecodeClientEnvelope(raw)
21		require.Error(t, err)
22	}
23}
24
25// TestRouteRetiredRequiresNonzeroReference restores validation parity: a
26// retirement must carry the nonzero reference fence on both the encode and
27// decode sides of the wire conversion.
28func TestRouteRetiredRequiresNonzeroReference(t *testing.T) {
29	exact := protocol.ExactSessionTarget{LifecycleID: domain.SessionLifecycleID{3}, SessionName: "work"}
30	tests := []struct {
31		name  string
32		value protocol.RouteRetired
33	}{
34		{name: "zero reference", value: protocol.RouteRetired{Target: exact}},
35		{name: "missing generation", value: protocol.RouteRetired{Ref: protocol.RouteRef{Key: 1}, Target: exact}},
36		{name: "missing key", value: protocol.RouteRetired{Ref: protocol.RouteRef{Generation: 1}, Target: exact}},
37	}
38	for _, tt := range tests {
39		t.Run(tt.name, func(t *testing.T) {
40			_, err := routeRetiredToWire(tt.value)
41			require.ErrorIs(t, err, protocol.ErrInvalidRouteWire)
42
43			_, err = routeRetiredFromWire(&wire.RouteRetired{
44				Ref:    &wire.RouteRef{Key: tt.value.Ref.Key, Generation: tt.value.Ref.Generation},
45				Target: exactTargetToWire(&exact),
46			})
47			require.ErrorIs(t, err, protocol.ErrInvalidRouteWire)
48		})
49	}
50}

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