1
#![allow(missing_docs)]
2

            
3
use std::path::Path;
4

            
5
use bonsaidb_core::connection::AsyncStorageConnection;
6
use bonsaidb_core::test_util::BasicSchema;
7
use bonsaidb_local::config::Builder;
8

            
9
use crate::config::DefaultPermissions;
10
use crate::{BackendError, Server, ServerConfiguration};
11

            
12
pub const BASIC_SERVER_NAME: &str = "basic-server";
13

            
14
#[cfg_attr(not(feature = "compression"), allow(unused_mut))]
15
51
pub async fn initialize_basic_server(path: &Path) -> Result<Server, BackendError> {
16
38
    let mut config = ServerConfiguration::new(path)
17
38
        .server_name(BASIC_SERVER_NAME)
18
38
        .default_permissions(DefaultPermissions::AllowAll)
19
38
        .with_schema::<BasicSchema>()?;
20
    #[cfg(feature = "compression")]
21
38
    {
22
38
        config = config.default_compression(bonsaidb_local::config::Compression::Lz4);
23
38
    }
24
114
    let server = Server::open(config).await?;
25
38
    assert_eq!(server.primary_domain(), BASIC_SERVER_NAME);
26

            
27
377
    server.install_self_signed_certificate(false).await?;
28

            
29
38
    server
30
38
        .create_database::<BasicSchema>("tests", false)
31
76
        .await?;
32

            
33
38
    Ok(server)
34
38
}