Open robjtede opened 2 years ago
Would be great to have this implemented on the actix-web testing api. For now, a solution is to use another crate actix-multipart-rfc7578. Actix also use this crate to test their own lib like on the following block of code
#[actix_rt::test]
async fn test_file_upload() {
let srv = actix_test::start(|| App::new().route("/", web::post().to(test_file_route)));
let mut form = multipart::Form::default();
let bytes = Cursor::new("Hello, world!");
form.add_reader_file_with_mime("file", bytes, "testfile.txt", mime::TEXT_PLAIN);
let response = send_form(&srv, form, "/").await;
assert_eq!(response.status(), StatusCode::OK);
}
started working on this in #3288