1
#![allow(missing_docs)]
2

            
3
use std::path::Path;
4

            
5
use bonsaidb_core::{connection::StorageConnection, test_util::BasicSchema};
6
use bonsaidb_local::config::Builder;
7

            
8
use crate::{config::DefaultPermissions, Error, Server, ServerConfiguration};
9

            
10
pub const BASIC_SERVER_NAME: &str = "basic-server";
11

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

            
25
241
    server.install_self_signed_certificate(false).await?;
26

            
27
32
    server
28
64
        .create_database::<BasicSchema>("tests", false)
29
64
        .await?;
30

            
31
32
    Ok(server)
32
32
}