detached be1f2be

test(screencast): order the denied-peer assertion through the service and check setup errors

commit
be1f2be4ea6ca3dfaed5ea617f9c96f9a21e5e78
author
brice · · 2026-10-14 21:36 UTC
committer
brice · · 2026-10-14 21:39 UTC
parent
0516c4d
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +16 -12
M internal/adapters/screencast/bus_test.go +5 -5
@@ -672,15 +672,15 @@ func TestInventorySignalsGoToAllowedPeersOnly(t *testing.T) {
672672 t.Fatalf("allowed peer heard %v", seen)
673673 }
674674 }
675- // A round trip through the service orders the signals before its answer:
676- // the denied peer would have heard them by now.
675+ // The service's owner goroutine answers in order: a call that it
676+ // answers (AccessDenied) comes after any signal it had wrongly directed
677+ // to this connection. The handler is active during the call.
677678 denied.Handle = func(m *zerobus.Message) {
678679 if m.Member == "WindowsChanged" || m.Member == "MonitorsChanged" {
679680 t.Errorf("refused peer got %s", m.Member)
680681 }
681682 }
682- denied.NewCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetId", "")
683- if _, err := denied.Call(); err != nil {
684- t.Fatal(err)
683+ if name, _ := callErr(denied, nameIntrospect, pathIntrospect, ifaceIntrospect, "GetWindows", "", nil); name != errAccessDenied {
684+ t.Fatalf("refused peer: %q", name)
685685 }
686686 }
@@ -672,15 +672,15 @@ func TestInventorySignalsGoToAllowedPeersOnly(t *testing.T) {
672 t.Fatalf("allowed peer heard %v", seen)672 t.Fatalf("allowed peer heard %v", seen)
673 }673 }
674 }674 }
675- // A round trip through the service orders the signals before its answer:675+ // The service's owner goroutine answers in order: a call that it
676- // the denied peer would have heard them by now.676+ // answers (AccessDenied) comes after any signal it had wrongly directed
677+ // to this connection. The handler is active during the call.
677 denied.Handle = func(m *zerobus.Message) {678 denied.Handle = func(m *zerobus.Message) {
678 if m.Member == "WindowsChanged" || m.Member == "MonitorsChanged" {679 if m.Member == "WindowsChanged" || m.Member == "MonitorsChanged" {
679 t.Errorf("refused peer got %s", m.Member)680 t.Errorf("refused peer got %s", m.Member)
680 }681 }
681 }682 }
682- denied.NewCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "GetId", "")683+ if name, _ := callErr(denied, nameIntrospect, pathIntrospect, ifaceIntrospect, "GetWindows", "", nil); name != errAccessDenied {
683- if _, err := denied.Call(); err != nil {684+ t.Fatalf("refused peer: %q", name)
684- t.Fatal(err)
685 }685 }
686 }686 }
M internal/adapters/screencast/screenshot_test.go +11 -7
@@ -169,22 +169,26 @@ func TestScreenshotWithoutUsableFileIsNotSuccess(t *testing.T) {
169169 if err := os.WriteFile(target, []byte("png"), 0o600); err != nil {
170170 t.Fatal(err)
171171 }
172- for name, mk := range map[string]func(path string){
173- "missing": func(string) {},
174- "empty": func(path string) { _ = os.WriteFile(path, nil, 0o600) },
175- "symlink": func(path string) { _ = os.Symlink(target, path) },
176- "dir": func(path string) { _ = os.Mkdir(path, 0o700) },
172+ for name, mk := range map[string]func(path string) error{
173+ "missing": func(string) error { return nil },
174+ "empty": func(path string) error { return os.WriteFile(path, nil, 0o600) },
175+ "symlink": func(path string) error { return os.Symlink(target, path) },
176+ "dir": func(path string) error { return os.Mkdir(path, 0o700) },
177177 } {
178178 t.Run(name, func(t *testing.T) {
179179 h, c := ready(t, harnessOpts{})
180180 h.run.EXPECT().Run(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, args []string) error {
181- mk(args[slices.Index(args, "-file")+1])
181+ if err := mk(args[slices.Index(args, "-file")+1]); err != nil {
182+ t.Error(err)
183+ }
182184 return nil
183185 }).Once()
184186 for _, member := range []string{"Screenshot", "InteractiveScreenshot"} {
185187 if member == "InteractiveScreenshot" {
186188 h.run.EXPECT().Run(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, args []string) error {
187- mk(args[slices.Index(args, "-file")+1])
189+ if err := mk(args[slices.Index(args, "-file")+1]); err != nil {
190+ t.Error(err)
191+ }
188192 return nil
189193 }).Once()
190194 }
@@ -169,22 +169,26 @@ func TestScreenshotWithoutUsableFileIsNotSuccess(t *testing.T) {
169 if err := os.WriteFile(target, []byte("png"), 0o600); err != nil {169 if err := os.WriteFile(target, []byte("png"), 0o600); err != nil {
170 t.Fatal(err)170 t.Fatal(err)
171 }171 }
172- for name, mk := range map[string]func(path string){172+ for name, mk := range map[string]func(path string) error{
173- "missing": func(string) {},173+ "missing": func(string) error { return nil },
174- "empty": func(path string) { _ = os.WriteFile(path, nil, 0o600) },174+ "empty": func(path string) error { return os.WriteFile(path, nil, 0o600) },
175- "symlink": func(path string) { _ = os.Symlink(target, path) },175+ "symlink": func(path string) error { return os.Symlink(target, path) },
176- "dir": func(path string) { _ = os.Mkdir(path, 0o700) },176+ "dir": func(path string) error { return os.Mkdir(path, 0o700) },
177 } {177 } {
178 t.Run(name, func(t *testing.T) {178 t.Run(name, func(t *testing.T) {
179 h, c := ready(t, harnessOpts{})179 h, c := ready(t, harnessOpts{})
180 h.run.EXPECT().Run(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, args []string) error {180 h.run.EXPECT().Run(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, args []string) error {
181- mk(args[slices.Index(args, "-file")+1])181+ if err := mk(args[slices.Index(args, "-file")+1]); err != nil {
182+ t.Error(err)
183+ }
182 return nil184 return nil
183 }).Once()185 }).Once()
184 for _, member := range []string{"Screenshot", "InteractiveScreenshot"} {186 for _, member := range []string{"Screenshot", "InteractiveScreenshot"} {
185 if member == "InteractiveScreenshot" {187 if member == "InteractiveScreenshot" {
186 h.run.EXPECT().Run(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, args []string) error {188 h.run.EXPECT().Run(mock.Anything, mock.Anything).RunAndReturn(func(_ context.Context, args []string) error {
187- mk(args[slices.Index(args, "-file")+1])189+ if err := mk(args[slices.Index(args, "-file")+1]); err != nil {
190+ t.Error(err)
191+ }
188 return nil192 return nil
189 }).Once()193 }).Once()
190 }194 }

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 25

Tags 10

↑↓ moveenter openesc close