Build test utils only in 'go test'

This commit is contained in:
Soam Vasani
2016-08-31 11:00:42 -07:00
parent 2b0b2e28ae
commit 53eeff3c44
+27
View File
@@ -0,0 +1,27 @@
package router
import (
"net/http"
"log"
"io/ioutil"
)
func testRequest(targetUrl string, expectedResponse string) {
resp, err := http.Get(targetUrl)
if (err != nil) {
log.Panic("failed make get request")
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if (err != nil) {
log.Panic("failed to read response")
}
bodyStr := string(body)
log.Printf("Server responded with %v", bodyStr)
if (bodyStr != expectedResponse) {
log.Panic("Unexpected response")
}
}