Move log test helpers to separate package.

This commit is contained in:
Joachim Bauch 2026-01-12 13:58:33 +01:00
commit ee6f026bbb
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
42 changed files with 236 additions and 151 deletions

View file

@ -29,11 +29,11 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/strukturag/nextcloud-spreed-signaling/log"
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
)
func CreateLoopbackClientForTest(t *testing.T) Client {
logger := log.NewLoggerForTest(t)
logger := logtest.NewLoggerForTest(t)
result, err := NewLoopbackClient(logger)
require.NoError(t, err)
t.Cleanup(func() {

View file

@ -35,6 +35,7 @@ import (
"github.com/nats-io/nats.go"
"github.com/strukturag/nextcloud-spreed-signaling/log"
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
"github.com/strukturag/nextcloud-spreed-signaling/test"
)
@ -59,7 +60,7 @@ func StartLocalServerPort(t *testing.T, port int) (*server.Server, int) {
func CreateLocalClientForTest(t *testing.T, options ...nats.Option) (*server.Server, int, Client) {
t.Helper()
server, port := StartLocalServer(t)
logger := log.NewLoggerForTest(t)
logger := logtest.NewLoggerForTest(t)
ctx := log.NewLoggerContext(t.Context(), logger)
result, err := NewClient(ctx, server.ClientURL(), options...)
require.NoError(t, err)

View file

@ -30,6 +30,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/strukturag/nextcloud-spreed-signaling/log"
logtest "github.com/strukturag/nextcloud-spreed-signaling/log/test"
"github.com/strukturag/nextcloud-spreed-signaling/nats"
)
@ -42,7 +43,7 @@ func TestLocalServer(t *testing.T) {
server, port := StartLocalServer(t)
assert.NotEqual(0, port)
ctx := log.NewLoggerContext(t.Context(), log.NewLoggerForTest(t))
ctx := log.NewLoggerContext(t.Context(), logtest.NewLoggerForTest(t))
client, err := nats.NewClient(ctx, server.ClientURL())
require.NoError(err)
@ -56,7 +57,7 @@ func TestWaitForSubscriptionsEmpty(t *testing.T) {
require := require.New(t)
assert := assert.New(t)
ctx := log.NewLoggerContext(t.Context(), log.NewLoggerForTest(t))
ctx := log.NewLoggerContext(t.Context(), logtest.NewLoggerForTest(t))
client, err := nats.NewClient(ctx, nats.LoopbackUrl)
require.NoError(err)