@@ -109,6 +109,34 @@ func TestDoSuccessful(t *testing.T) {
109
109
assert .Equal (t , map [string ]string {"responseValue" : "someValueOut" }, result )
110
110
})
111
111
112
+ t .Run ("slice as request and response" , func (t * testing.T ) {
113
+ ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
114
+ body , _ := ioutil .ReadAll (r .Body )
115
+ assert .Equal (t , `[{"requestValue":"someValueIn"}]` + "\n " , string (body ))
116
+ assert .Equal (t , r .Method , http .MethodPost )
117
+ w .WriteHeader (http .StatusCreated )
118
+ _ , err := w .Write ([]byte (`[{"key1": "value1"}, {"key2": "value2"}]` ))
119
+ assert .NoError (t , err )
120
+ }))
121
+ defer ts .Close ()
122
+
123
+ params := Params {
124
+ URL : ts .URL ,
125
+ Method : http .MethodPost ,
126
+ Body : []map [string ]interface {}{{"requestValue" : "someValueIn" }},
127
+ ExpectedResponseCode : http .StatusCreated ,
128
+ }
129
+
130
+ result := []map [string ]interface {}{}
131
+ err := Do (params , & result )
132
+ assert .NoError (t , err )
133
+ expected := []map [string ]interface {}{
134
+ {"key1" : "value1" },
135
+ {"key2" : "value2" },
136
+ }
137
+ assert .Equal (t , expected , result )
138
+ })
139
+
112
140
t .Run ("with query" , func (t * testing.T ) {
113
141
ts := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
114
142
assert .Equal (t , r .URL .RawQuery , `beenhere=before&testKey=testValue&%C3%B6%C3%A4=%25%26%2F` )
0 commit comments