(t *testing.T, url, expectAck string)
| 41 | } |
| 42 | |
| 43 | func validPage(t *testing.T, url, expectAck string) { |
| 44 | c := &http.Client{ |
| 45 | Timeout: time.Second * 5, |
| 46 | } |
| 47 | resp, err := c.Get(url) |
| 48 | if err != nil { |
| 49 | t.Log("http req failed", err) |
| 50 | t.FailNow() |
| 51 | } |
| 52 | |
| 53 | defer resp.Body.Close() |
| 54 | bodyData, err := ioutil.ReadAll(resp.Body) |
| 55 | if err != nil { |
| 56 | t.Log("http response failed", err) |
| 57 | t.FailNow() |
| 58 | } |
| 59 | |
| 60 | body := string(bodyData) |
| 61 | |
| 62 | if body != expectAck { |
| 63 | t.Log("unexpect result", err, body) |
| 64 | t.FailNow() |
| 65 | } |
| 66 | } |