detached 2d72cbf

refactor(brokeripc): move test-only SocketDir out of production

commit
2d72cbf9c4a1bcc133f2d44fe4364051b4484568
author
brice · · 2026-09-23 12:11 UTC
parent
f2870bb
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
3 files · +13 -10
M internal/adapters/brokeripc/export_test.go +11 -0
@@ -1,5 +1,9 @@
11 package brokeripc
22
3+import (
4+ "github.com/bnema/vev/internal/adapters/ipc"
5+)
6+
37 // Test-only accessors (export_test.go pattern): these observe listener
48 // internals that only this package's own tests need. They are kept out of
59 // the production build so a live server's diagnostics or capacity never
@@ -32,3 +36,10 @@ func (l *listener) liveSessions() int {
3236 // convenience default runtime directory, for tests that need it without
3337 // composing SocketPath(SocketDir()) themselves.
3438 func DefaultSocketPath() string { return SocketPath(SocketDir()) }
39+
40+// SocketDir returns the per-user directory the broker endpoint belongs in:
41+// $XDG_RUNTIME_DIR/vev when set, else /run/user/<uid>/vev when that directory
42+// exists, else /tmp/vev-<uid>. It is the daemon's per-user runtime directory as
43+// well, so both endpoints share one owner-only directory while keeping
44+// distinct socket names.
45+func SocketDir() string { return ipc.SocketDir() }
@@ -1,5 +1,9 @@
1 package brokeripc1 package brokeripc
2 2
3+import (
4+ "github.com/bnema/vev/internal/adapters/ipc"
5+)
6+
3 // Test-only accessors (export_test.go pattern): these observe listener7 // Test-only accessors (export_test.go pattern): these observe listener
4 // internals that only this package's own tests need. They are kept out of8 // internals that only this package's own tests need. They are kept out of
5 // the production build so a live server's diagnostics or capacity never9 // the production build so a live server's diagnostics or capacity never
@@ -32,3 +36,10 @@ func (l *listener) liveSessions() int {
32 // convenience default runtime directory, for tests that need it without36 // convenience default runtime directory, for tests that need it without
33 // composing SocketPath(SocketDir()) themselves.37 // composing SocketPath(SocketDir()) themselves.
34 func DefaultSocketPath() string { return SocketPath(SocketDir()) }38 func DefaultSocketPath() string { return SocketPath(SocketDir()) }
39+
40+// SocketDir returns the per-user directory the broker endpoint belongs in:
41+// $XDG_RUNTIME_DIR/vev when set, else /run/user/<uid>/vev when that directory
42+// exists, else /tmp/vev-<uid>. It is the daemon's per-user runtime directory as
43+// well, so both endpoints share one owner-only directory while keeping
44+// distinct socket names.
45+func SocketDir() string { return ipc.SocketDir() }
M internal/adapters/brokeripc/socket.go +0 -9
@@ -2,8 +2,6 @@ package brokeripc
22
33 import (
44 "path/filepath"
5-
6- "github.com/bnema/vev/internal/adapters/ipc"
75 )
86
97 // SocketFileName is the fixed name of the per-user broker IPC socket inside its
@@ -16,10 +14,3 @@ const SocketFileName = "broker.sock"
1614 func SocketPath(runtimeDir string) string {
1715 return filepath.Join(runtimeDir, SocketFileName)
1816 }
19-
20-// SocketDir returns the per-user directory the broker endpoint belongs in:
21-// $XDG_RUNTIME_DIR/vev when set, else /run/user/<uid>/vev when that directory
22-// exists, else /tmp/vev-<uid>. It is the daemon's per-user runtime directory as
23-// well, so both endpoints share one owner-only directory while keeping
24-// distinct socket names.
25-func SocketDir() string { return ipc.SocketDir() }
@@ -2,8 +2,6 @@ package brokeripc
2 2
3 import (3 import (
4 "path/filepath"4 "path/filepath"
5-
6- "github.com/bnema/vev/internal/adapters/ipc"
7 )5 )
8 6
9 // SocketFileName is the fixed name of the per-user broker IPC socket inside its7 // SocketFileName is the fixed name of the per-user broker IPC socket inside its
@@ -16,10 +14,3 @@ const SocketFileName = "broker.sock"
16 func SocketPath(runtimeDir string) string {14 func SocketPath(runtimeDir string) string {
17 return filepath.Join(runtimeDir, SocketFileName)15 return filepath.Join(runtimeDir, SocketFileName)
18 }16 }
19-
20-// SocketDir returns the per-user directory the broker endpoint belongs in:
21-// $XDG_RUNTIME_DIR/vev when set, else /run/user/<uid>/vev when that directory
22-// exists, else /tmp/vev-<uid>. It is the daemon's per-user runtime directory as
23-// well, so both endpoints share one owner-only directory while keeping
24-// distinct socket names.
25-func SocketDir() string { return ipc.SocketDir() }
M internal/app/broker_offline_status_test.go +2 -1
@@ -17,6 +17,7 @@ import (
1717
1818 "github.com/bnema/vev/internal/adapters/brokerconfig"
1919 "github.com/bnema/vev/internal/adapters/brokeripc"
20+ "github.com/bnema/vev/internal/adapters/ipc"
2021 "github.com/bnema/vev/internal/adapters/lifecycle"
2122 )
2223
@@ -444,7 +445,7 @@ func TestBrokerStatusEnsureRejectsUnsafeRoot(t *testing.T) {
444445 root string
445446 }{
446447 {name: "relative root", root: "relative"},
447- {name: "production overlap", root: brokeripc.SocketDir()},
448+ {name: "production overlap", root: ipc.SocketDir()},
448449 }
449450 for _, tt := range tests {
450451 t.Run(tt.name, func(t *testing.T) {
@@ -17,6 +17,7 @@ import (
17 17
18 "github.com/bnema/vev/internal/adapters/brokerconfig"18 "github.com/bnema/vev/internal/adapters/brokerconfig"
19 "github.com/bnema/vev/internal/adapters/brokeripc"19 "github.com/bnema/vev/internal/adapters/brokeripc"
20+ "github.com/bnema/vev/internal/adapters/ipc"
20 "github.com/bnema/vev/internal/adapters/lifecycle"21 "github.com/bnema/vev/internal/adapters/lifecycle"
21 )22 )
22 23
@@ -444,7 +445,7 @@ func TestBrokerStatusEnsureRejectsUnsafeRoot(t *testing.T) {
444 root string445 root string
445 }{446 }{
446 {name: "relative root", root: "relative"},447 {name: "relative root", root: "relative"},
447- {name: "production overlap", root: brokeripc.SocketDir()},448+ {name: "production overlap", root: ipc.SocketDir()},
448 }449 }
449 for _, tt := range tests {450 for _, tt := range tests {
450 t.Run(tt.name, func(t *testing.T) {451 t.Run(tt.name, func(t *testing.T) {

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