Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 420 Bytes

README.md

File metadata and controls

21 lines (17 loc) · 420 Bytes

NetTest

Network helpers when for testing against networks

$ go get github.com/graze/golang-service/nettest
done := make(chan string)
addr, sock, srvWg := nettest.CreateServer(t, "tcp", ":0", done)
defer srvWg.Wait()
defer os.Remove(addr.String())
defer sock.Close()

s, err := net.Dial("tcp", addr.String())
fmt.Fprintf(s, msg + "\n")
if msg = "\n" != <-done {
    panic("message mismatch")
}