fix: close conn

This commit is contained in:
Kevin Franklin Kim 2025-05-16 22:34:51 +02:00
parent ff7d3da5d1
commit 368dcf4f3f
No known key found for this signature in database

View File

@ -8,7 +8,6 @@ import (
"github.com/foomo/contentserver/client"
"github.com/foomo/contentserver/pkg/handler"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"
@ -36,9 +35,13 @@ func initSocketRepoServer(tb testing.TB, l *zap.Logger) net.Listener {
// listen on socket
ln, err := nettest.NewLocalListener("tcp")
require.NoError(tb, err)
go func() {
<-tb.Context().Done()
_ = ln.Close()
}()
go func() {
for {
// this blocks until connection or error
@ -54,7 +57,6 @@ func initSocketRepoServer(tb testing.TB, l *zap.Logger) net.Listener {
go func() {
l.Debug("accepted connection", zap.String("source", conn.RemoteAddr().String()))
h.Serve(conn)
assert.NoError(tb, conn.Close())
}()
}
}()