Commit
+38 -4 +/-2 browse
1 | diff --git a/tests/common/mod.rs b/tests/common/mod.rs |
2 | index 5ff6fc8..b8d17e7 100644 |
3 | --- a/tests/common/mod.rs |
4 | +++ b/tests/common/mod.rs |
5 | @@ -65,6 +65,21 @@ impl GitRepo { |
6 | Ok(Self { repo }) |
7 | } |
8 | |
9 | + pub fn clone_repo(&self) -> io::Result<Self> { |
10 | + let repo = tempfile::TempDir::new()?; |
11 | + let src_dir_str = self |
12 | + .repo |
13 | + .path() |
14 | + .to_str() |
15 | + .expect("could not convert src repo path to str"); |
16 | + let dst_dir_str = repo |
17 | + .path() |
18 | + .to_str() |
19 | + .expect("could not convert src repo path to str"); |
20 | + cmd!("git", "clone", src_dir_str, dst_dir_str).run()?; |
21 | + Ok(Self { repo }) |
22 | + } |
23 | + |
24 | /// Adds a random file with the given size and random number generator. The |
25 | /// file is also staged with `git add`. |
26 | pub fn add_random<R: Rng>( |
27 | @@ -99,6 +114,11 @@ impl GitRepo { |
28 | Ok(()) |
29 | } |
30 | |
31 | + pub fn pull(&self) -> io::Result<()> { |
32 | + cmd!("git", "pull").dir(self.repo.path()).run()?; |
33 | + Ok(()) |
34 | + } |
35 | + |
36 | /// Deletes all cached LFS files in `.git/lfs/`. This will force a |
37 | /// re-download from the server. |
38 | pub fn clean_lfs(&self) -> io::Result<()> { |
39 | diff --git a/tests/test_local.rs b/tests/test_local.rs |
40 | index 2af9b6f..646b7ee 100644 |
41 | --- a/tests/test_local.rs |
42 | +++ b/tests/test_local.rs |
43 | @@ -59,13 +59,27 @@ async fn local_smoke_test() -> Result<(), Box<dyn std::error::Error>> { |
44 | // Make sure we can push LFS objects to the server. |
45 | repo.lfs_push()?; |
46 | |
47 | - // Make sure we can re-download the same objects. |
48 | - repo.clean_lfs()?; |
49 | - repo.lfs_pull()?; |
50 | - |
51 | // Push again. This should be super fast. |
52 | repo.lfs_push()?; |
53 | |
54 | + // This should be fast since we already have the data |
55 | + repo.lfs_pull()?; |
56 | + |
57 | + // Make sure we can re-download the same objects in another repo |
58 | + let repo_clone = repo.clone_repo().expect("unable to clone"); |
59 | + |
60 | + // This should be fast since the lfs data should come along properly with |
61 | + // the clone |
62 | + repo_clone.lfs_pull()?; |
63 | + |
64 | + // Add some more files and make sure you can pull those into the clone |
65 | + repo.add_random(Path::new("4mb_2.bin"), 4 * 1024 * 1024, &mut rng)?; |
66 | + repo.add_random(Path::new("8mb_2.bin"), 8 * 1024 * 1024, &mut rng)?; |
67 | + repo.add_random(Path::new("16mb_2.bin"), 16 * 1024 * 1024, &mut rng)?; |
68 | + repo.commit("Add LFS objects 2")?; |
69 | + |
70 | + repo_clone.pull()?; |
71 | + |
72 | shutdown_tx.send(()).expect("server died too soon"); |
73 | |
74 | if let Either::Right((result, _)) = server.await? { |