mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-18 04:43:12 +02:00
Refactorings for simplify readability (#35)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package proxy_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/cirruslabs/orchard/internal/controller/proxy"
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/require"
|
||||
"net"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestProxy(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
expectedConn, _ := net.Pipe()
|
||||
|
||||
proxy := proxy.NewProxy()
|
||||
|
||||
token := uuid.New().String()
|
||||
|
||||
connCh, cancel := proxy.Request(ctx, token)
|
||||
defer cancel()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
_, err := proxy.Respond(token, expectedConn)
|
||||
require.NoError(t, err)
|
||||
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
actualConn := <-connCh
|
||||
require.Equal(t, expectedConn, actualConn)
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
Reference in New Issue
Block a user