From 3dee953cd2080155f41a2835bafd3aaf596684aa Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 30 Mar 2026 09:08:22 -0400 Subject: [PATCH] Add git_init() helper to TestContext Initializes a git repo in temp_dir. Replaces the local init_git_repo() helper in repo.rs tests. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/crates/fabro-cli/tests/it/cmd/repo.rs | 14 +++----------- lib/crates/fabro-test/src/lib.rs | 10 ++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/crates/fabro-cli/tests/it/cmd/repo.rs b/lib/crates/fabro-cli/tests/it/cmd/repo.rs index d64bde7af..92c4f89d1 100644 --- a/lib/crates/fabro-cli/tests/it/cmd/repo.rs +++ b/lib/crates/fabro-cli/tests/it/cmd/repo.rs @@ -1,13 +1,5 @@ use fabro_test::{fabro_snapshot, test_context}; -fn init_git_repo(path: &std::path::Path) { - std::process::Command::new("git") - .args(["init"]) - .current_dir(path) - .output() - .expect("git init should succeed"); -} - fn init_fabro_project(context: &fabro_test::TestContext) { context .write_temp("fabro.toml", "version = 1\n") @@ -47,7 +39,7 @@ fn help() { #[test] fn test_repo_deinit_removes_fabro_toml_and_dir() { let context = test_context!(); - init_git_repo(&context.temp_dir); + context.git_init(); init_fabro_project(&context); assert!(context.temp_dir.join("fabro.toml").exists()); @@ -73,7 +65,7 @@ fn test_repo_deinit_removes_fabro_toml_and_dir() { #[test] fn test_repo_deinit_fails_when_not_initialized() { let context = test_context!(); - init_git_repo(&context.temp_dir); + context.git_init(); let mut cmd = context.repo(); cmd.arg("deinit"); @@ -90,7 +82,7 @@ fn test_repo_deinit_fails_when_not_initialized() { #[test] fn test_repo_init_skill_installs_skill_files() { let context = test_context!(); - init_git_repo(&context.temp_dir); + context.git_init(); context .repo() diff --git a/lib/crates/fabro-test/src/lib.rs b/lib/crates/fabro-test/src/lib.rs index de9fa82a7..4f583c287 100644 --- a/lib/crates/fabro-test/src/lib.rs +++ b/lib/crates/fabro-test/src/lib.rs @@ -223,6 +223,16 @@ impl TestContext { self } + /// Initialize a git repository in `temp_dir`. + pub fn git_init(&self) -> &Self { + std::process::Command::new("git") + .args(["init"]) + .current_dir(&self.temp_dir) + .output() + .expect("git init should succeed"); + self + } + /// Write a file under `home_dir`, creating parent directories as needed. /// /// `path` is relative to `home_dir`.