コード例 #1
0
ファイル: assertions.go プロジェクト: dolab/httptesting
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
ファイル: assertions.go プロジェクト: dolab/httptesting
// 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
ファイル: assertions.go プロジェクト: dolab/httptesting
// 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+".")
}