-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking multipart uploads #39
Comments
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");
} |
Lol. you're right :) Here's my examples: |
Hi, is it also possible to match binary content? |
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:
The text was updated successfully, but these errors were encountered: