forked from electricdusk/rushlink
Add a test for issue #56
This commit is contained in:
parent
2883af7d31
commit
70538f170f
@ -159,3 +159,26 @@ func TestIssue60(t *testing.T) {
|
||||
srv.ServeHTTP(rr, req)
|
||||
checkStatusCode(t, rr, http.StatusNotFound)
|
||||
}
|
||||
|
||||
func TestIssue56(t *testing.T) {
|
||||
srv, _ := createTemporaryRouter(t)
|
||||
|
||||
// Make a POST request with both a 'file' *and* a 'shorten' part.
|
||||
var body bytes.Buffer
|
||||
form := multipart.NewWriter(&body)
|
||||
if _, err := form.CreateFormFile("file", "empty.txt"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := form.CreateFormField("shorten"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
form.Close()
|
||||
req, err := http.NewRequest("POST", "/", bytes.NewReader(body.Bytes()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
req.Header.Add("Content-Type", form.FormDataContentType())
|
||||
rr := httptest.NewRecorder()
|
||||
srv.ServeHTTP(rr, req)
|
||||
checkStatusCode(t, rr, http.StatusBadRequest)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user