trillium_testing/
methods.rs

1/*!
2[`TestConn`](crate::TestConn) builders for http methods
3*/
4
5macro_rules! method {
6    ($fn_name:ident, $method:ident) => {
7        method!(
8            $fn_name,
9            $method,
10            concat!(
11                // yep, macro-generated doctests
12                "Builds a new [`TestConn`](crate::TestConn) with the ",
13                stringify!($fn_name),
14                " http method and the provided path.
15
16```
17use trillium_testing::prelude::*;
18
19let conn = ",
20                stringify!($fn_name),
21                "(\"/some/route\").on(&());
22
23assert_eq!(conn.method(), Method::",
24                stringify!($method),
25                ");
26assert_eq!(conn.path(), \"/some/route\");
27```
28"
29            )
30        );
31    };
32
33    ($fn_name:ident, $method:ident, $doc_comment:expr) => {
34        #[doc = $doc_comment]
35        pub fn $fn_name(path: impl Into<String>) -> $crate::TestConn {
36            $crate::TestConn::build($crate::prelude::Method::$method, path, ())
37        }
38    };
39}
40
41method!(get, Get);
42method!(post, Post);
43method!(put, Put);
44method!(delete, Delete);
45method!(patch, Patch);