From 755e28d044aaff9a8aa0fa4700105564726ec33d Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Fri, 14 Jul 2023 13:13:11 +0200 Subject: Add a housekeeping task, which does git gc --- tests/cli.rs | 13 ++++++++----- tests/cli_test_utils/git.rs | 9 +++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/cli.rs b/tests/cli.rs index 0520e89..598152b 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -273,7 +273,6 @@ fn can_delete_a_repo() -> Result<()> { } #[test] -#[ignore] fn git_housekeeping_repacks_objects() -> Result<()> { let mut c = TestContext::new_interactive()?; let repo_path = personal_repo_path(REPO_NAME); @@ -284,11 +283,15 @@ fn git_housekeeping_repacks_objects() -> Result<()> { let checkout_dir = create_clone(&c, &repo_dir, REPO_NAME); create_commit(&checkout_dir)?; + push(&checkout_dir, "main"); + + let packs_dir = repo_dir.join("objects").join("pack"); + + assert_eq!(packs_dir.read_dir()?.count(), 0); + c.p.send_line(&format!("housekeeping {repo_path}"))?; + c.p.exp_string(&format!("Successfully did housekeeping on \"{repo_path}\""))?; + assert!(packs_dir.read_dir()?.count() > 0); - // push to the repo - // check that objects exist, not packs - // run housekeeping - // check that only packs exist Ok(()) } diff --git a/tests/cli_test_utils/git.rs b/tests/cli_test_utils/git.rs index 150af45..fe6e1bd 100644 --- a/tests/cli_test_utils/git.rs +++ b/tests/cli_test_utils/git.rs @@ -46,6 +46,15 @@ pub fn create_commit(repo_dir: &Path) -> Result { Ok(commit_hash) } +pub fn push(local_repo_dir: &Path, branch: &str) { + Command::new("git") + .args(["push", "origin", branch]) + .current_dir(&local_repo_dir) + .timeout(std::time::Duration::from_secs(3)) + .assert() + .success(); +} + pub fn verify_repo_exists(repo_dir: &Path) { Command::new("git") .arg("rev-list") -- cgit v1.2.3