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

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

use sequoia_ipc::core::{Context, IPCPolicy};
use sequoia_store::{Mapping, REALM_CONTACTS};
use sequoia_net as net;

const P: net::Policy = net::Policy::Offline;

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

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

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

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