1
0
mirror of https://github.com/j178/prek.git synced 2026-04-03 17:34:03 +02:00

Improve tests (#106)

* Improve tests

* Fix
This commit is contained in:
Jo
2024-11-23 21:34:48 +08:00
committed by GitHub
parent 4ddc3cf93f
commit 3113e8400a
4 changed files with 12 additions and 9 deletions

View File

@@ -5,6 +5,6 @@ uv = { max-threads = 1}
# due to concurrent uv cache writes.
# Configure these tests to run sequentially.
[[profile.default.overrides]]
filter = 'test(run_basic) | test(local_need_install)'
filter = 'binary(run) and test(/run_basic|local_need_install/)'
platform = 'cfg(windows)'
test-group = 'uv'

View File

@@ -184,25 +184,27 @@ impl TestContext {
.current_dir(&self.temp_dir)
.assert()
.success();
}
/// Configure git user and email.
pub fn configure_git_author(&self) {
Command::new("git")
.arg("config")
.current_dir(&self.temp_dir)
.arg("user.name")
.arg("Test User")
.arg("Pre-Commit Test")
.current_dir(&self.temp_dir)
.assert()
.success();
Command::new("git")
.arg("config")
.current_dir(&self.temp_dir)
.arg("user.email")
.arg("test@example.com")
.arg("test@pre-commit-rs.dev")
.current_dir(&self.temp_dir)
.assert()
.success();
}
/// Run `git add` in the temporary directory.
/// Run `git add`.
pub fn git_add(&self, path: impl AsRef<OsStr>) {
Command::new("git")
.arg("add")
@@ -212,7 +214,7 @@ impl TestContext {
.success();
}
/// Run `git commit` in the temporary directory.
/// Run `git commit`.
pub fn git_commit(&self, message: &str) {
Command::new("git")
.arg("commit")

View File

@@ -25,7 +25,7 @@ fn hook_impl() {
"});
context.git_add(".");
context.configure_git_author();
let mut commit = Command::new("git");
commit
.arg("commit")

View File

@@ -728,6 +728,7 @@ fn merge_conflicts() -> Result<()> {
let cwd = context.workdir();
cwd.child("file.txt").write_str("Hello, world!")?;
context.git_add(".");
context.configure_git_author();
context.git_commit("Initial commit");
Command::new("git")