1
1
use core::fmt::Debug;
2

            
3
use bonsaidb::core::schema::{Collection, CollectionName, Schema, Schematic};
4

            
5
1
#[test]
6
1
fn core() {
7
1
    #[derive(Schema, Debug)]
8
1
    #[schema(name = "name", core = ::bonsaidb::core)]
9
1
    struct Test<T: Sync + Send + Debug + 'static>(T);
10
1

            
11
1
    assert_eq!(
12
1
        Test::<String>::schema_name(),
13
1
        bonsaidb::core::schema::SchemaName::private("name")
14
1
    );
15
1
}
16

            
17
1
#[test]
18
1
fn name_only() {
19
1
    #[derive(Schema, Debug)]
20
1
    #[schema(name = "name")]
21
1
    struct Test<T: Sync + Send + Debug + 'static>(T);
22
1

            
23
1
    assert_eq!(
24
1
        Test::<String>::schema_name(),
25
1
        bonsaidb::core::schema::SchemaName::private("name")
26
1
    );
27
1
}
28
1
#[test]
29
1
fn name_and_authority() {
30
1
    #[derive(Schema, Debug)]
31
1
    #[schema(name = "name", authority = "authority")]
32
1
    struct Test<T: Sync + Send + Debug + 'static>(T);
33
1

            
34
1
    assert_eq!(
35
1
        Test::<String>::schema_name(),
36
1
        bonsaidb::core::schema::SchemaName::new("authority", "name")
37
1
    );
38
1
}
39
1
#[test]
40
1
fn collections() {
41
1
    #[derive(Schema, Debug)]
42
1
    #[schema(name = "name", authority = "authority", collections = [TestCollection])]
43
1
    struct TestSchema;
44
1

            
45
1
    let schematic = Schematic::from_schema::<TestSchema>().unwrap();
46
1
    assert!(schematic
47
1
        .collections()
48
1
        .contains(&CollectionName::private("name")));
49

            
50
2
    #[derive(Collection, Debug)]
51
    #[collection(name = "name")]
52
    struct TestCollection;
53
1
}