(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestDumpRequestWithJSON(t *testing.T) { |
| 17 | t.Run("should be indented", func(t *testing.T) { |
| 18 | req, _ := http.NewRequest("GET", "/withJSON", bytes.NewBuffer( |
| 19 | []byte(`{"foo": "bar", "a": [1,2,3]}`), |
| 20 | )) |
| 21 | req.Header.Set("Content-Type", "application/json") |
| 22 | |
| 23 | buf, err := DumpRequest(req) |
| 24 | require.NoError(t, err) |
| 25 | fmt.Printf("%s\n", buf) |
| 26 | }) |
| 27 | |
| 28 | t.Run("should be displayed as is", func(t *testing.T) { |
| 29 | req, _ := http.NewRequest("GET", "/invalidJSON", bytes.NewBuffer( |
| 30 | []byte(`invalid json`), |
| 31 | )) |
| 32 | req.Header.Set("Content-Type", "application/json") |
| 33 | |
| 34 | buf, err := DumpRequest(req) |
| 35 | require.NoError(t, err) |
| 36 | fmt.Printf("%s\n", buf) |
| 37 | }) |
| 38 | } |
| 39 | |
| 40 | func TestDumpRequestHeaders(t *testing.T) { |
| 41 | t.Run("request headers should be dumped in sorted order", func(t *testing.T) { |
nothing calls this directly
no test coverage detected