feat: Store.parse_store_path()

(cherry picked from commit 6b92d4164b94d5030929dfb56577b1fd8d62e067)
This commit is contained in:
Robert Hensing 2024-12-17 09:54:28 +01:00
parent c9d54ccbc6
commit c986c09b8c
2 changed files with 55 additions and 0 deletions

View file

@ -71,3 +71,17 @@ impl Drop for StorePath {
}
}
}
#[cfg(test)]
mod tests {
#[test]
#[cfg(nix_at_least = "2.26" /* get_storedir */)]
fn store_path_name() {
let mut store = crate::store::Store::open("dummy://", []).unwrap();
let store_dir = store.get_storedir().unwrap();
let store_path_string =
format!("{store_dir}/rdd4pnr4x9rqc9wgbibhngv217w2xvxl-bash-interactive-5.2p26");
let store_path = store.parse_store_path(store_path_string.as_str()).unwrap();
assert_eq!(store_path.name().unwrap(), "bash-interactive-5.2p26");
}
}