Files
fission-src/router/util_test.go
T
Soam Vasani 2aa4c58556 Move packages to root dir from src/
This is supposed to work slightly better with go import paths. I think.
2016-09-07 14:07:26 -07:00

31 lines
588 B
Go

package router
import (
"io/ioutil"
"log"
"net/http"
)
func testRequest(targetUrl string, expectedResponse string) {
resp, err := http.Get(targetUrl)
if err != nil {
log.Panicf("failed to make get request: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
log.Panicf("response status: %v", resp.StatusCode)
}
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")
}
}