MCPcopy Create free account
hub / github.com/goadesign/goa / TestResponseDecoder

Function TestResponseDecoder

http/encoding_test.go:235–274  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

233}
234
235func TestResponseDecoder(t *testing.T) {
236 cases := []struct {
237 contentType string
238 decoderType string
239 }{
240 {"application/json", "*json.Decoder"},
241 {"+json", "*json.Decoder"},
242 {"application/xml", "*xml.Decoder"},
243 {"+xml", "*xml.Decoder"},
244 {"application/gob", "*gob.Decoder"},
245 {"+gob", "*gob.Decoder"},
246 {"text/html", "*http.textDecoder"},
247 {"+html", "*http.textDecoder"},
248 {"text/plain", "*http.textDecoder"},
249 {"+txt", "*http.textDecoder"},
250 {"application/json; charset=utf-8", "*json.Decoder"},
251 {"+json; charset=utf-8", "*json.Decoder"},
252 {"application/xml; charset=utf-8", "*xml.Decoder"},
253 {"+xml; charset=utf-8", "*xml.Decoder"},
254 {"application/gob; charset=utf-8", "*gob.Decoder"},
255 {"+gob; charset=utf-8", "*gob.Decoder"},
256 {"text/html; charset=utf-8", "*http.textDecoder"},
257 {"+html; charset=utf-8", "*http.textDecoder"},
258 {"text/plain; charset=utf-8", "*http.textDecoder"},
259 {"+txt; charset=utf-8", "*http.textDecoder"},
260 }
261
262 for _, c := range cases {
263 t.Run(c.contentType, func(t *testing.T) {
264 r := &http.Response{
265 Header: map[string][]string{
266 "Content-Type": {c.contentType},
267 },
268 }
269 decoder := ResponseDecoder(r)
270
271 assert.Equal(t, c.decoderType, fmt.Sprintf("%T", decoder))
272 })
273 }
274}
275
276func TestTextEncoder_Encode(t *testing.T) {
277 cases := []struct {

Callers

nothing calls this directly

Calls 2

ResponseDecoderFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected