parseMultipartParts parses a multipart/mixed response and returns a map from Content-Type to body bytes.
(t *testing.T, contentType string, body []byte)
| 1304 | // parseMultipartParts parses a multipart/mixed response and returns |
| 1305 | // a map from Content-Type to body bytes. |
| 1306 | func parseMultipartParts(t *testing.T, contentType string, body []byte) map[string][]byte { |
| 1307 | t.Helper() |
| 1308 | _, params, err := mime.ParseMediaType(contentType) |
| 1309 | require.NoError(t, err, "parse Content-Type") |
| 1310 | boundary := params["boundary"] |
| 1311 | require.NotEmpty(t, boundary, "missing boundary") |
| 1312 | mr := multipart.NewReader(bytes.NewReader(body), boundary) |
| 1313 | parts := make(map[string][]byte) |
| 1314 | for { |
| 1315 | part, err := mr.NextPart() |
| 1316 | if errors.Is(err, io.EOF) { |
| 1317 | break |
| 1318 | } |
| 1319 | require.NoError(t, err, "unexpected multipart parse error") |
| 1320 | ct := part.Header.Get("Content-Type") |
| 1321 | data, readErr := io.ReadAll(part) |
| 1322 | require.NoError(t, readErr) |
| 1323 | parts[ct] = data |
| 1324 | } |
| 1325 | return parts |
| 1326 | } |
| 1327 | |
| 1328 | func TestHandleRecordingStop_WithThumbnail(t *testing.T) { |
| 1329 | t.Parallel() |
no test coverage detected