MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / probe

Function probe

atomic-repository/tests/it/database_lock_exclusivity_test.rs:23–46  ·  view source on GitHub ↗
(root: &Path)

Source from the content-addressed store, hash-verified

21}
22
23fn probe(root: &Path) -> String {
24 let readonly = match Repository::open_readonly_wait(root, Duration::ZERO) {
25 Ok(_) => "readonly-ok".to_string(),
26 Err(RepositoryError::DatabaseBusy) => "readonly-busy".to_string(),
27 Err(e) => format!("readonly-other: {e}"),
28 };
29 let readwrite = match Repository::open_existing_wait(root, Duration::ZERO) {
30 Ok(_) => "readwrite-ok".to_string(),
31 Err(RepositoryError::DatabaseBusy) => "readwrite-busy".to_string(),
32 Err(e) => format!("readwrite-other: {e}"),
33 };
34 // The journal opens native redb against the same database the repository
35 // opens through SnapshotBackend. Neither may bypass the other's lock.
36 let journal = match RedbChangeStore::open_existing(root.join(".atomic/atomic.redb")) {
37 Ok(_) => "journal-ok".to_string(),
38 Err(RedbStoreError::Database(e))
39 if matches!(*e, redb::DatabaseError::DatabaseAlreadyOpen) =>
40 {
41 "journal-busy".to_string()
42 }
43 Err(e) => format!("journal-other: {e}"),
44 };
45 format!("{readonly} {readwrite} {journal}")
46}
47
48fn child_probe(root: &Path, report_path: &Path) -> String {
49 let mut child = Command::new(std::env::current_exe().expect("test binary path"))

Calls

no outgoing calls

Tested by

no test coverage detected