summaryrefslogtreecommitdiffstats
path: root/store/tests/ipc-policy.rs
blob: ccac8369c25b87261a6b31f1644804f41850faa9 (plain)
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
use sequoia_core;
use sequoia_store;

use std::env::current_exe;
use std::path::PathBuf;

use sequoia_core::{Context, NetworkPolicy, IPCPolicy};
use sequoia_store::{Mapping, REALM_CONTACTS};

#[test]
fn ipc_policy_external() {
    let ctx = Context::configure()
        .ephemeral()
        .lib(current_exe().unwrap().parent().unwrap().parent().unwrap())
        .network_policy(NetworkPolicy::Offline)
        .ipc_policy(IPCPolicy::External)
        .build().unwrap();
    Mapping::open(&ctx, REALM_CONTACTS, "default").unwrap();
}

#[test]
fn ipc_policy_internal() {
    let ctx = Context::configure()
        .ephemeral()
        .lib(PathBuf::from("/i/do/not/exist"))
        .network_policy(NetworkPolicy::Offline)
        .ipc_policy(IPCPolicy::Internal)
        .build().unwrap();
    Mapping::open(&ctx, REALM_CONTACTS, "default").unwrap();
}

#[test]
fn ipc_policy_robust() {
    let ctx = Context::configure()
        .ephemeral()
        .lib(current_exe().unwrap().parent().unwrap().parent().unwrap())
        .network_policy(NetworkPolicy::Offline)
        .ipc_policy(IPCPolicy::Robust)
        .build().unwrap();
    Mapping::open(&ctx, REALM_CONTACTS, "default").unwrap();

    let ctx = Context::configure()
        .ephemeral()
        .lib(PathBuf::from("/i/do/not/exist"))
        .network_policy(NetworkPolicy::Offline)
        .ipc_policy(IPCPolicy::Robust)
        .build().unwrap();
    Mapping::open(&ctx, REALM_CONTACTS, "default").unwrap();
}