mirror of https://github.com/statping/statping
travis-ci updates
parent
7765075c27
commit
cbabd2f8fa
|
@ -169,21 +169,21 @@ func TestDeleteDirectory(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHttpRequest(t *testing.T) {
|
||||
// Start a local HTTP server
|
||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
// Test request parameters
|
||||
assert.Equal(t, req.URL.String(), "/")
|
||||
assert.Equal(t, req.Header["Aaa"], []string{"bbbb="})
|
||||
assert.Equal(t, req.Header["Ccc"], []string{"ddd"})
|
||||
// Send response to be tested
|
||||
rw.Write([]byte(`OK`))
|
||||
}))
|
||||
// Close the server when test finishes
|
||||
defer server.Close()
|
||||
|
||||
body, resp, err := HttpRequest(server.URL, "GET", "application/json", []string{"aaa=bbbb=", "ccc=ddd"}, nil, 2*time.Second)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, []byte("OK"), body)
|
||||
assert.Equal(t, resp.StatusCode, 200)
|
||||
}
|
||||
// Start a local HTTP server
|
||||
server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
// Test request parameters
|
||||
assert.Equal(t, req.URL.String(), "/")
|
||||
assert.Equal(t, req.Header["Aaa"], []string{"bbbb="})
|
||||
assert.Equal(t, req.Header["Ccc"], []string{"ddd"})
|
||||
// Send response to be tested
|
||||
rw.Write([]byte(`OK`))
|
||||
}))
|
||||
// Close the server when test finishes
|
||||
defer server.Close()
|
||||
|
||||
body, resp, err := HttpRequest(server.URL, "GET", "application/json", []string{"aaa=bbbb=", "ccc=ddd"}, nil, 2*time.Second, false)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, []byte("OK"), body)
|
||||
assert.Equal(t, resp.StatusCode, 200)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue