Beispiel #1
0
func TestResponse(t *testing.T) {
	under := new(http.Response)
	under.Status = "the status message"
	under.StatusCode = 392
	under.Header = make(http.Header)
	under.Header.Set("Blah", "blah blah")
	under.Body = ioutil.NopCloser(bytes.NewBufferString("some content"))

	var resp client.Response = response{under}
	assert.EqualValues(t, under.StatusCode, resp.Code())
	assert.Equal(t, under.Status, resp.Message())
	assert.Equal(t, "blah blah", resp.GetHeader("blah"))
	assert.Equal(t, under.Body, resp.Body())
}
Beispiel #2
0
func (o *ListTasksOK) readResponse(response client.Response, consumer httpkit.Consumer, formats strfmt.Registry) error {

	// response header X-Last-Task-Id
	xLastTaskId, err := swag.ConvertInt64(response.GetHeader("X-Last-Task-Id"))
	if err != nil {
		return errors.InvalidType("X-Last-Task-Id", "header", "int64", response.GetHeader("X-Last-Task-Id"))
	}
	o.XLastTaskID = xLastTaskId

	// response payload
	if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
		return err
	}

	return nil
}