예제 #1
0
파일: recorder.go 프로젝트: yarpc/yarpc-go
func (r *Recorder) responseToResponseRecord(response *transport.Response) responseRecord {
	responseBody, err := ioutil.ReadAll(response.Body)
	if err != nil {
		r.logger.Fatal(err)
	}
	response.Body = ioutil.NopCloser(bytes.NewReader(responseBody))
	return responseRecord{
		Headers: response.Headers.Items(),
		Body:    responseBody,
	}
}
예제 #2
0
파일: reqres.go 프로젝트: yarpc/yarpc-go
// NewResponseMatcher builds a new ResponseMatcher that verifies that
// responses match the given Response.
func NewResponseMatcher(t *testing.T, r *transport.Response) ResponseMatcher {
	body, err := ioutil.ReadAll(r.Body)
	defer r.Body.Close()
	if err != nil {
		t.Fatalf("failed to read response body: %v", err)
	}

	// restore a copy of the body so that the caller can still use the
	// response object
	r.Body = ioutil.NopCloser(bytes.NewReader(body))
	return ResponseMatcher{t: t, res: r, body: body}
}