Closed ayrat555 closed 3 years ago
Thanks for creating this issue. Multipart uploads are currently not supported but are far up on the todo list.
Ok. Thanks. I think it should be mentioned somewhere.
I just tested my example with mockito. It works fine
@ayrat555: You linked the Java version of mockito obove. Did you maybe mean the Rust mockito library? Because AFAICS, mockito (Rust) does not mention multipart support anywhere in the docs either.
I just tested your code locally, but it successfully ran through. Could you maybe provide a reproducable example with the problem you have?
My version is as follows:
#[test]
fn multipart_body_test() {
#[derive(serde::Serialize, serde::Deserialize)]
struct ExampleStruct {
my_key: String,
}
// Arrange
let server = MockServer::start();
let mock = server.mock(|when, then| {
when.method("POST").path("/hello");
then.status(200).json_body_obj(&ExampleStruct{my_key: "my value".into()});
});
let path = get_test_data_path("tests/resources/static_yaml_mock.yaml");
let res : Result<ExampleStruct, ureq::Error> = request_with_form_data(
"hello",
json!({ "my_key" : "my value" , "anotherKey": "some other value" }),
"my_key",
path,
&server.base_url()
);
mock.assert();
assert_eq!(res.is_ok(), true);
assert_eq!(res.unwrap().my_key, "my value");
}
You linked the Java version of mockito obove. Did you maybe mean the Rust mockito library? Because AFAICS, mockito (Rust) does not mention multipart support anywhere in the docs either.
Lol. you're right :)
Here's my examples:
Should be fixed with PR #40 in v0.5.8. I have successfully tested your repo with it but please feel free to reopen this issue if it still fails on you for some reason.
Hi, is it also possible to match binary content? body
is from type String
. It would be great to have a helper method when.body_from_file
that reads a file from the file system. This would be congruent with then.body_from_file
.
It seems the library fails on
multipart/form-data
uploads. It works fine with regular requests with json body.Requests to real server upload files without any issues. I'm using
ureq
as HTTP client:mock: