Skip to content

Commit fd648ac

Browse files
committed
Adding integration test
Signed-off-by: Matt Macdonald <matt.david.macdonald@gmail.com>
1 parent 292b251 commit fd648ac

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

mocktail-tests/tests/examples/http_unary.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,31 @@ async fn test_unary_headers() -> Result<(), Error> {
184184

185185
Ok(())
186186
}
187+
188+
#[tokio::test]
189+
async fn test_unary_form_body() -> Result<(), Error> {
190+
let mut mocks = MockSet::new();
191+
mocks.mock(|when, then| {
192+
when.post()
193+
.header("content-type", "application/x-www-form-urlencoded")
194+
.form(FormBody::new().field("name", "world"));
195+
then.text("hello world");
196+
});
197+
198+
let server = MockServer::new_http("form").with_mocks(mocks);
199+
server.start().await?;
200+
201+
let client = reqwest::Client::builder().http2_prior_knowledge().build()?;
202+
203+
let response = client
204+
.post(server.url("/form"))
205+
.form(&[("name", "world")])
206+
.send()
207+
.await?;
208+
209+
assert_eq!(response.status(), http::StatusCode::OK);
210+
let res = response.text().await?;
211+
assert_eq!(res, "hello world");
212+
213+
Ok(())
214+
}

0 commit comments

Comments
 (0)