// Writes the input from a test case into a buffer using the multipart writer.
Writes the input from a test case into a buffer using the multipart writer.
// Writes the input from a test case into a buffer using the multipart writer .
func makeMultipartPayload(testCase multipartFormTestCase) (*bytes.Buffer, *multipart.Writer) {
	body := &bytes.Buffer{}
	writer := multipart.NewWriter(body)
	if testCase.malformEncoding {
		body.Write([]byte(`--` + writer.Boundary() + `\nContent-Disposition: form-data; name="foo"\n\n--` + writer.Boundary() + `--`))
		return body, writer
	} else {
		_ = writer.WriteField("title", testCase.inputAndExpected.Title)
		_ = writer.WriteField("content", testCase.inputAndExpected.Content)
		_ = writer.WriteField("id", strconv.Itoa(testCase.inputAndExpected.Id))
		_ = writer.WriteField("ignored", testCase.inputAndExpected.Ignored)
		for _, value := range testCase.inputAndExpected.Ratings {
			_ = writer.WriteField("rating", strconv.Itoa(value))
		}
		_ = writer.WriteField("name", testCase.inputAndExpected.Author.Name)
		_ = writer.WriteField("email", testCase.inputAndExpected.Author.Email)
		return body, writer
	}
}
func makeMultipartPayload ( testCase multipartFormTestCase ) ( * bytes . Buffer , * multipart . Writer ) { body := & bytes . Buffer { } writer := multipart . NewWriter ( body ) if testCase . malformEncoding { body . Write ( [ ] byte ( `--` + writer . Boundary ( ) + `\nContent-Disposition: form-data; name="foo"\n\n--` + writer . Boundary ( ) + `--` ) ) return body , writer } else { _ = writer . WriteField ( " " , testCase . inputAndExpected . Title ) _ = writer . WriteField ( " " , testCase . inputAndExpected . Content ) _ = writer . WriteField ( " " , strconv . Itoa ( testCase . inputAndExpected . Id ) ) _ = writer . WriteField ( " " , testCase . inputAndExpected . Ignored ) for _ , value := range testCase . inputAndExpected . Ratings { _ = writer . WriteField ( " " , strconv . Itoa ( value ) ) } _ = writer . WriteField ( " " , testCase . inputAndExpected . Author . Name ) _ = writer . WriteField ( " " , testCase . inputAndExpected . Author . Email ) return body , writer } }
Writes the input from a test case into a buffer using the multipart writer.
Writes the input from a test case into a buffer using the multipart writer .
// TODO: Break the multipart form parser which is apparently impervious!! // (Get it to return an error. Trying to get 100% test coverage.)