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

Function TestRequestEncoder

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

Source from the content-addressed store, hash-verified

23)
24
25func TestRequestEncoder(t *testing.T) {
26 const (
27 ct = "Content-Type"
28 ctJSON = "application/json"
29 ctOther = "<other>"
30 wantT = "*json.Encoder"
31 )
32 cases := []struct {
33 name string
34 requestCT string
35 wantCT string
36 }{
37 {"no ct", "", ctJSON},
38 {"json ct", ctJSON, ctJSON},
39 {"other ct", ctOther, ctOther},
40 }
41 for _, c := range cases {
42 t.Run(c.name, func(t *testing.T) {
43 r := &http.Request{Header: http.Header{}}
44 if c.requestCT != "" {
45 r.Header.Set(ct, c.requestCT)
46 }
47
48 _ = RequestEncoder(r)
49
50 assert.Equal(t, c.wantCT, r.Header.Get(ct))
51 })
52 }
53}
54
55func TestRequestEncoderGetBody(t *testing.T) {
56 r := &http.Request{Header: http.Header{}}

Callers

nothing calls this directly

Calls 4

SetMethod · 0.80
RequestEncoderFunction · 0.70
RunMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected