1
0
mirror of https://github.com/golang/go synced 2024-10-02 18:18:33 -06:00

rpc: use httptest.Server for tests

R=golang-dev, rsc1, rsc
CC=golang-dev
https://golang.org/cl/4253060
This commit is contained in:
Robert Hencke 2011-03-07 10:37:10 -05:00 committed by Russ Cox
parent c6093e6b82
commit c7ef0fd26b

View File

@ -6,7 +6,7 @@ package rpc
import (
"fmt"
"http"
"http/httptest"
"log"
"net"
"os"
@ -103,11 +103,9 @@ func startNewServer() {
}
func startHttpServer() {
var l net.Listener
l, httpServerAddr = listenTCP()
httpServerAddr = l.Addr().String()
server := httptest.NewServer(nil)
httpServerAddr = server.Listener.Addr().String()
log.Println("Test HTTP RPC server listening on", httpServerAddr)
go http.Serve(l, nil)
}
func TestRPC(t *testing.T) {