...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package client
16
17 import (
18 "bytes"
19 "io"
20 "net/http"
21 "testing"
22
23 "github.com/stretchr/testify/assert"
24
25 "github.com/go-openapi/runtime"
26 )
27
28 func TestResponse(t *testing.T) {
29 under := new(http.Response)
30 under.Status = "the status message"
31 under.StatusCode = 392
32 under.Header = make(http.Header)
33 under.Header.Set("Blah", "blahblah")
34 under.Body = io.NopCloser(bytes.NewBufferString("some content"))
35
36 var resp runtime.ClientResponse = response{under}
37 assert.EqualValues(t, under.StatusCode, resp.Code())
38 assert.Equal(t, under.Status, resp.Message())
39 assert.Equal(t, "blahblah", resp.GetHeader("blah"))
40 assert.Equal(t, []string{"blahblah"}, resp.GetHeaders("blah"))
41 assert.Equal(t, under.Body, resp.Body())
42 }
43
View as plain text