detached 9b5cbc8

test(idle): cover Close error propagation and idempotency

commit
9b5cbc8a46d75d945ec4bc53c6fe2a174ce7471d
author
brice · · 2026-10-14 09:57 UTC
parent
cf96431
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +6 -4
M internal/infrastructure/idle/portal_inhibitor_test.go +6 -4
@@ -85,11 +85,13 @@ func TestPortalInhibitorRollsBackFailedInhibit(t *testing.T) {
8585
8686 func TestPortalInhibitorClose(t *testing.T) {
8787 tests := []struct {
88- name string
89- inhibit bool
88+ name string
89+ inhibit bool
90+ closeErr error
9091 }{
9192 {name: "releases active request", inhibit: true},
9293 {name: "without active request"},
94+ {name: "returns connection close error once", closeErr: errPortal},
9395 }
9496 for _, tt := range tests {
9597 t.Run(tt.name, func(t *testing.T) {
@@ -99,9 +101,9 @@ func TestPortalInhibitorClose(t *testing.T) {
99101 portal.EXPECT().CloseRequest(testHandle).Return(nil).Once()
100102 require.NoError(t, p.Inhibit(context.Background(), "video playing"))
101103 }
102- portal.EXPECT().Close().Return(nil).Once()
104+ portal.EXPECT().Close().Return(tt.closeErr).Once()
103105
104- require.NoError(t, p.Close())
106+ require.ErrorIs(t, p.Close(), tt.closeErr)
105107 require.False(t, p.IsInhibited())
106108 // Close is idempotent.
107109 require.NoError(t, p.Close())
@@ -85,11 +85,13 @@ func TestPortalInhibitorRollsBackFailedInhibit(t *testing.T) {
85 85
86 func TestPortalInhibitorClose(t *testing.T) {86 func TestPortalInhibitorClose(t *testing.T) {
87 tests := []struct {87 tests := []struct {
88- name string88+ name string
89- inhibit bool89+ inhibit bool
90+ closeErr error
90 }{91 }{
91 {name: "releases active request", inhibit: true},92 {name: "releases active request", inhibit: true},
92 {name: "without active request"},93 {name: "without active request"},
94+ {name: "returns connection close error once", closeErr: errPortal},
93 }95 }
94 for _, tt := range tests {96 for _, tt := range tests {
95 t.Run(tt.name, func(t *testing.T) {97 t.Run(tt.name, func(t *testing.T) {
@@ -99,9 +101,9 @@ func TestPortalInhibitorClose(t *testing.T) {
99 portal.EXPECT().CloseRequest(testHandle).Return(nil).Once()101 portal.EXPECT().CloseRequest(testHandle).Return(nil).Once()
100 require.NoError(t, p.Inhibit(context.Background(), "video playing"))102 require.NoError(t, p.Inhibit(context.Background(), "video playing"))
101 }103 }
102- portal.EXPECT().Close().Return(nil).Once()104+ portal.EXPECT().Close().Return(tt.closeErr).Once()
103 105
104- require.NoError(t, p.Close())106+ require.ErrorIs(t, p.Close(), tt.closeErr)
105 require.False(t, p.IsInhibited())107 require.False(t, p.IsInhibited())
106 // Close is idempotent.108 // Close is idempotent.
107 require.NoError(t, p.Close())109 require.NoError(t, p.Close())

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 8

Tags 42

↑↓ moveenter openesc close