1
use core::fmt::Debug;
2

            
3
use bonsaidb::core::api::{Api, ApiName};
4
use bonsaidb::core::schema::Qualified;
5
use serde::{Deserialize, Serialize};
6

            
7
1
#[test]
8
1
fn core() {
9
1
    #[derive(Api, Debug, Serialize, Deserialize)]
10
1
    #[api(name = "name", core = ::bonsaidb::core)]
11
1
    struct Test;
12
1

            
13
1
    assert_eq!(Test::name(), ApiName::private("name"));
14
1
}
15

            
16
1
#[test]
17
1
fn name_only() {
18
1
    #[derive(Api, Debug, Serialize, Deserialize)]
19
1
    #[api(name = "name")]
20
1
    struct Test;
21
1

            
22
1
    assert_eq!(Test::name(), ApiName::private("name"));
23
1
}
24
1
#[test]
25
1
fn name_and_authority() {
26
1
    #[derive(Api, Debug, Serialize, Deserialize)]
27
1
    #[api(name = "name", authority = "authority")]
28
1
    struct Test;
29
1

            
30
1
    assert_eq!(Test::name(), ApiName::new("authority", "name"));
31
1
}
32
1
#[test]
33
1
fn error() {
34
1
    #[derive(Api, Debug, Serialize, Deserialize)]
35
1
    #[api(name = "name", authority = "authority", error = String)]
36
1
    struct Test;
37
1

            
38
1
    assert_eq!(<Test as Api>::Error::new(), String::new());
39
1
}
40
1
#[test]
41
1
fn response() {
42
1
    #[derive(Api, Debug, Serialize, Deserialize)]
43
1
    #[api(name = "name", authority = "authority", response = String)]
44
1
    struct Test;
45
1

            
46
1
    assert_eq!(<Test as Api>::Response::new(), String::new());
47
1
}