From c736369e170dd1522b63e4d4bc349b513e398c22 Mon Sep 17 00:00:00 2001 From: welpo Date: Sun, 4 Feb 2024 18:28:37 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20disable=20GPG=20signing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensures tests aren't influenced by local Git configuration. --- tests/lint/test_commit_changes.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/lint/test_commit_changes.rs b/tests/lint/test_commit_changes.rs index f1cdfdb..30fcd54 100644 --- a/tests/lint/test_commit_changes.rs +++ b/tests/lint/test_commit_changes.rs @@ -15,9 +15,29 @@ fn setup_git_repo() -> TempDir { let tmp_dir = TempDir::new().expect("Failed to create a temporary directory"); let repo_dir = tmp_dir.path(); + // Initialize a git repository. Command::new("git") .args(["init"]) - .current_dir(repo_dir) + .current_dir(&repo_dir) + .assert() + .success(); + + // Disable GPG signing (otherwise it can prompt for a passphrase during tests). + Command::new("git") + .args(["config", "commit.gpgsign", "false"]) + .current_dir(&repo_dir) + .assert() + .success(); + + // Set the user name and email. + Command::new("git") + .args(["config", "user.name", "Test User"]) + .current_dir(&repo_dir) + .assert() + .success(); + Command::new("git") + .args(["config", "user.email", "test@example.com"]) + .current_dir(&repo_dir) .assert() .success();