(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func 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 | |
| 55 | func TestRequestEncoderGetBody(t *testing.T) { |
| 56 | r := &http.Request{Header: http.Header{}} |
nothing calls this directly
no test coverage detected