mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-28 07:30:51 +08:00
We add tests for ODB functionality, as well as a new `TreeBuilder` Struct to make building git trees easier (see below). The `git2::TreeBuilder` can be a pain to use since it has a lifetime that is tied to the `git2::Repository`. This was causing issues when trying to write generators for property tests. Instead, define a custom TreeBuilder which is a defunctionalised list operations that represent the `insert` and `remove` methods on `git2::TreeBuilder`. The implementation of writing a tree then becomes converting the custom `TreeBuilder` into a `git2::TreeBuilder`. Signed-off-by: Jorge Iglesias Garcia <me@jorgeig.com>
15 lines
413 B
Rust
15 lines
413 B
Rust
use git2::Repository;
|
|
use git_storage::{signature::UserInfo, Write};
|
|
use test_helpers::tempdir::WithTmpDir;
|
|
|
|
pub type TmpWriter = WithTmpDir<Write>;
|
|
pub type TmpRepo = WithTmpDir<Repository>;
|
|
|
|
pub fn writer(user: UserInfo) -> TmpWriter {
|
|
WithTmpDir::new(|path| {
|
|
Write::open(path, user)
|
|
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("{}", e)))
|
|
})
|
|
.unwrap()
|
|
}
|