converge/pkg/testsupport/inmemoryconnection_test.go
Erik Brakkee dca0772dc3 fixed issue with ChannelReadWriter for unbuffered channels.
Was a concurrency issue int he Write method that retained the
slice p that was passed in, making concurrency issues much more likely
with unbuffered channels.
2024-08-21 16:32:37 +02:00

46 lines
884 B
Go

package testsupport
import (
"context"
"github.com/stretchr/testify/suite"
"net/http"
"testing"
"time"
)
type InMemoryTestSuite struct {
suite.Suite
pprofServer *http.Server
ctx context.Context
cancelFunc context.CancelFunc
pipe *InmemoryConnection
}
func TestInMemoryConnectionTestSuite(t *testing.T) {
suite.Run(t, &InMemoryTestSuite{})
}
func (s *InMemoryTestSuite) createConnection() {
ctx, cancelFunc := CreateTestContext(context.Background(), 10*time.Second)
s.ctx = ctx
s.cancelFunc = cancelFunc
s.pipe = NewInmemoryConnection(ctx, "inmemory", 10)
}
func (s *InMemoryTestSuite) SetupSuite() {
s.pprofServer = StartPprof("")
}
func (s *InMemoryTestSuite) TearDownSuite() {
StopPprof(s.ctx, s.pprofServer)
}
func (s *InMemoryTestSuite) SetupTest() {
s.createConnection()
}
func (s *InMemoryTestSuite) TearDownTest() {
s.cancelFunc()
}