27 lines
447 B
Go
27 lines
447 B
Go
package modular
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestModularServerClient(t *testing.T) {
|
|
// Find an ephemeral port
|
|
lis, err := net.Listen("tcp", "127.0.0.1:0")
|
|
if err != nil {
|
|
t.Fatalf("failed to listen: %v", err)
|
|
}
|
|
addr := lis.Addr().String()
|
|
lis.Close()
|
|
|
|
// Start server in background
|
|
go ServerRun(addr)
|
|
|
|
// Wait for server to start
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
// Run client against the server
|
|
ClientRun(addr)
|
|
}
|