Skip to content

Commit 8a1bc25

Browse files
committed
test for auto-clone (#16)
1 parent 45494f0 commit 8a1bc25

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ git-testtools = "0.8.0"
2828
# git-repository = "0.22.1"
2929
git-repository = { version = "0.22.1", git = "https://github.com/Byron/gitoxide", branch = "for-crates-index-diff" }
3030
tempdir = "0.3.5"
31-
serial_test = "0.6.0"

tests/index/mod.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use crates_index_diff::Index;
2+
use git_testtools::tempfile::TempDir;
3+
use std::path::PathBuf;
24

35
mod changes_from_objects;
46

@@ -32,14 +34,31 @@ fn peek_changes() {
3234
);
3335
}
3436

35-
mod old;
37+
#[test]
38+
fn clone_if_needed() {
39+
let tmp = TempDir::new().unwrap();
40+
let options = || crates_index_diff::index::CloneOptions {
41+
repository_url: fixture_dir().unwrap().join("base").display().to_string(),
42+
fetch_options: None,
43+
};
44+
Index::from_path_or_cloned_with_options(tmp.path(), options())
45+
.expect("successful clone to be created");
46+
Index::from_path_or_cloned_with_options(tmp.path(), options())
47+
.expect("second instance re-uses existing clone");
48+
}
3649

3750
fn index_ro() -> crate::Result<Index> {
38-
let dir = git_testtools::scripted_fixture_repo_read_only_with_args(
51+
let dir = fixture_dir()?;
52+
Ok(Index::from_path_or_cloned(dir.join("clone"))?)
53+
}
54+
55+
fn fixture_dir() -> crate::Result<PathBuf> {
56+
Ok(git_testtools::scripted_fixture_repo_read_only_with_args(
3957
"make-index-from-parts.sh",
4058
std::env::current_dir()
4159
.ok()
4260
.map(|p| p.to_str().unwrap().to_owned()),
43-
)?;
44-
Ok(Index::from_path_or_cloned(dir.join("clone"))?)
61+
)?)
4562
}
63+
64+
mod old;

tests/index/old.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
use crates_index_diff::*;
22
use git2::Reference;
3-
use serial_test::serial;
43
use std::{env, path::PathBuf};
54
use tempdir::TempDir;
65

76
const NUM_VERSIONS_AT_RECENT_COMMIT: usize = 39752;
87
const REV_ONE_UNYANKED: &str = "f8cb00181";
98

10-
#[test]
11-
#[ignore] // This test takes too long for my taste, this library is stable by now
12-
fn clone_if_needed() {
13-
let tmp = TempDir::new("new-index").unwrap();
14-
Index::from_path_or_cloned(tmp.path()).expect("successful clone to be created");
15-
Index::from_path_or_cloned(tmp.path()).expect("second instance re-uses existing clone");
16-
}
17-
189
fn make_index() -> (Index, TempDir) {
1910
let tmp = TempDir::new("new-index").unwrap();
2011
let index = Index::from_path_or_cloned(
@@ -34,7 +25,6 @@ fn origin_master_of(index: &Index) -> Reference<'_> {
3425
}
3526

3627
#[test]
37-
#[serial]
3828
#[ignore]
3929
fn quick_changes_since_last_fetch() {
4030
let (mut index, _tmp) = make_index();

0 commit comments

Comments
 (0)