From c8c78ffd81b296c9231a537ca479620b266c4d29 Mon Sep 17 00:00:00 2001 From: SaladDay <1203511142@qq.com> Date: Wed, 7 Oct 2026 14:58:55 +0000 Subject: [PATCH] Move session defaults into the test helper --- services/core/internal/runtimegateway/owner_test.go | 2 +- services/core/internal/runtimegateway/session.go | 6 ------ services/core/internal/runtimegateway/session_test.go | 6 ++++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/core/internal/runtimegateway/owner_test.go b/services/core/internal/runtimegateway/owner_test.go index dc17a37b0..09ace7043 100644 --- a/services/core/internal/runtimegateway/owner_test.go +++ b/services/core/internal/runtimegateway/owner_test.go @@ -48,7 +48,7 @@ func TestSessionOwnerLeaseLostClosesStaleConnection(t *testing.T) { conn := newFakeConn() owners := &fakeOwnerStore{renewOK: false, releaseCh: make(chan struct{})} lease := &ownerLease{store: owners, deviceID: "dev-1", ownerPodID: "pod-a", generation: 7, ttl: time.Minute} - sess := NewSessionWithOwner(conn, "dev-1", "wks-1", proto.Version, reg, nil, lease) + sess := NewSessionWithOwner(conn, "dev-1", "wks-1", proto.Version, reg, func(string, ...any) {}, lease) reg.Register(sess) sess.Start() diff --git a/services/core/internal/runtimegateway/session.go b/services/core/internal/runtimegateway/session.go index 4643526a9..9032c2f48 100644 --- a/services/core/internal/runtimegateway/session.go +++ b/services/core/internal/runtimegateway/session.go @@ -146,12 +146,6 @@ type Session struct { // connections. The session does NOT start its goroutines automatically — Start // runs once the handler is ready so the session can't race with response writes. func NewSessionWithOwner(conn WSConn, deviceID, workspaceID, daemonVersion string, reg *Registry, log SessionLogger, owner *ownerLease) *Session { - if log == nil { - log = func(string, ...any) {} - } - if reg == nil { - reg = NewRegistry() - } now := time.Now() return &Session{ DeviceID: deviceID, diff --git a/services/core/internal/runtimegateway/session_test.go b/services/core/internal/runtimegateway/session_test.go index e32150e4b..c4e27e0f3 100644 --- a/services/core/internal/runtimegateway/session_test.go +++ b/services/core/internal/runtimegateway/session_test.go @@ -16,6 +16,12 @@ import ( // NewSession builds an unowned Session over a test connection. func NewSession(conn WSConn, deviceID, workspaceID, daemonVersion string, reg *Registry, log SessionLogger) *Session { + if log == nil { + log = func(string, ...any) {} + } + if reg == nil { + reg = NewRegistry() + } return NewSessionWithOwner(conn, deviceID, workspaceID, daemonVersion, reg, log, nil) }