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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// tui/tests/common/mod.rs
//
// Helpers shared by the integration tests. Every test binary compiles this
// module separately and uses a different subset of it, hence the blanket
// dead-code allow.
use ;
use ;
/// The workspace name test vaults index under, instead of the default
/// `<workspace>/kimun.sqlite`.
///
/// Both about not colliding with the code under test: `kimun.sqlite` is the
/// name the vault-local index has always had, so a test vault using it would
/// share a file with any code path that reaches for the default. The leading
/// dot also keeps the file out of the vault walk.
pub const TEST_INDEX_NAME: &str = ".test-index";
/// A [`SystemPath`] for a path a test has already made absolute (a `TempDir`,
/// a host literal). Panics rather than returning a `Result`: a test handing
/// over a relative path is a broken test, not a failure case.
/// [`VaultConfig`] for a test vault rooted at `dir`, indexed under
/// [`TEST_INDEX_NAME`].
/// Opens a test vault at `dir` with its database initialised.
///
/// Close it (`vault.close().await`) before the [`TempDir`] drops. The pool
/// holds the index file open — plus its `-wal`/`-shm` sidecars — and dropping
/// a pool only *schedules* the close; Windows then cannot `remove_dir_all` the
/// directory, an error `tempfile` swallows, so the leaked temp directory is
/// silent.
///
/// [`TempDir`]: tempfile::TempDir
pub async
/// Builds a genuinely absolute path for the host from `/`-separated
/// components.
///
/// A literal like `"/nonexistent/path"` is absolute on Unix but merely
/// *rooted* on Windows, where [`Path::is_absolute`] also wants a prefix
/// (`C:\`). Settings treat a rooted-but-prefixless path as relative and rebase
/// it onto the config directory, so a test written with the literal stops
/// testing what its name says.
///
/// [`Path::is_absolute`]: std::path::Path::is_absolute
/// [`absolute`] as the contents of a TOML string literal — Windows separators
/// have to survive TOML's own escaping.