1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
mod thruster_app;

#[cfg(not(feature = "hyper_server"))]
pub mod testing_async;

#[cfg(feature = "hyper_server")]
mod testing_hyper_async;

#[cfg(feature = "hyper_server")]
pub mod testing_async {
    pub use super::testing_hyper_async::*;
}

use async_trait::async_trait;
pub use httparse::Header;
pub use thruster_app::*;

use self::testing_async::TestResponse;

#[async_trait]
pub trait Testable {
    async fn get(
        &self,
        route: &str,
        headers: Vec<(String, String)>,
    ) -> Result<TestResponse, Box<dyn std::error::Error>>;
    async fn options(
        &self,
        route: &str,
        headers: Vec<(String, String)>,
    ) -> Result<TestResponse, Box<dyn std::error::Error>>;
    async fn post(
        &self,
        route: &str,
        headers: Vec<(String, String)>,
        body: Vec<u8>,
    ) -> Result<TestResponse, Box<dyn std::error::Error>>;
    async fn put(
        &self,
        route: &str,
        headers: Vec<(String, String)>,
        body: Vec<u8>,
    ) -> Result<TestResponse, Box<dyn std::error::Error>>;
    async fn delete(
        &self,
        route: &str,
        headers: Vec<(String, String)>,
    ) -> Result<TestResponse, Box<dyn std::error::Error>>;
    async fn patch(
        &self,
        route: &str,
        headers: Vec<(String, String)>,
        body: Vec<u8>,
    ) -> Result<TestResponse, Box<dyn std::error::Error>>;
}