示例#1
0
func (test *Client) AssertContainsJSON(key, value string) {
	actual, err := jsonparser.GetString(test.ResponseBody, strings.Split(key, ".")...)
	if err != nil {
		test.t.Errorf("Expected response body contains json key %s with %s, but got Errr(%v)", key, value, err)
	}

	assert.EqualValues(test.t, value, actual, "Expected response body contains json key "+key+" with "+value+", but got "+actual+".")
}
示例#2
0
// AssertHeader tests that the response includes named header with the given value.
func (test *Client) AssertHeader(name, value string) {
	name = http.CanonicalHeaderKey(name)
	actual := test.Response.Header.Get(name)

	assert.EqualValues(test.t, value, actual, "Expected response header "+name+" with "+value+", but got "+actual+".")
}
示例#3
0
// AssertStatus tests that the response status code is equal with the given.
func (test *Client) AssertStatus(status int) {
	assert.EqualValues(test.t, status, test.Response.StatusCode, "Expected response status code "+strconv.Itoa(status)+", but got "+test.Response.Status+".")
}