converge/pkg/testsupport/inmemoryconnection_test.go
Erik Brakkee ed04ac035a discovered net.Pipe for testing tcp connnections which makes the
previously developed ChannelReadWriter and InmemoryConnection obsolete.
2024-08-20 11:28:09 +02:00

46 lines
880 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")
}
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()
}