File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
mocktail-tests/tests/examples Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments