Creates a temporary Git repository for CLI testing.
()
| 7 | |
| 8 | /// Creates a temporary Git repository for CLI testing. |
| 9 | fn create_test_repo() -> TempDir { |
| 10 | let temp = TempDir::new().expect("Failed to create temp dir"); |
| 11 | let path = temp.path(); |
| 12 | |
| 13 | process::Command::new("git") |
| 14 | .args(["init"]) |
| 15 | .current_dir(path) |
| 16 | .output() |
| 17 | .expect("Failed to init git repo"); |
| 18 | |
| 19 | process::Command::new("git") |
| 20 | .args(["config", "user.email", "test@example.com"]) |
| 21 | .current_dir(path) |
| 22 | .output() |
| 23 | .expect("Failed to set email"); |
| 24 | |
| 25 | process::Command::new("git") |
| 26 | .args(["config", "user.name", "Test User"]) |
| 27 | .current_dir(path) |
| 28 | .output() |
| 29 | .expect("Failed to set name"); |
| 30 | |
| 31 | std::fs::write(path.join("README.md"), "# Test\n").expect("Failed to write file"); |
| 32 | |
| 33 | process::Command::new("git") |
| 34 | .args(["add", "."]) |
| 35 | .current_dir(path) |
| 36 | .output() |
| 37 | .expect("Failed to add files"); |
| 38 | |
| 39 | process::Command::new("git") |
| 40 | .args(["commit", "-m", "Initial commit"]) |
| 41 | .current_dir(path) |
| 42 | .output() |
| 43 | .expect("Failed to commit"); |
| 44 | |
| 45 | temp |
| 46 | } |
| 47 | |
| 48 | #[test] |
| 49 | fn test_help() { |
no test coverage detected