Skip to content

Commit

Permalink
chore: add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Oct 6, 2023
1 parent 4109273 commit 4349372
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions internal/lefthook/run/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func TestRunAll(t *testing.T) {
hook *config.Hook
success, fail []Result
gitCommands []string
force bool
}{
{
name: "empty hook",
Expand Down Expand Up @@ -673,6 +674,37 @@ func TestRunAll(t *testing.T) {
"git stash list",
},
},
{
name: "skippable pre-commit hook with force",
hookName: "pre-commit",
existingFiles: []string{
filepath.Join(root, "README.md"),
},
hook: &config.Hook{
Commands: map[string]*config.Command{
"ok": {
Run: "success",
StageFixed: true,
Glob: "*.md",
},
"fail": {
Run: "fail",
StageFixed: true,
Glob: "*.sh",
},
},
},
force: true,
success: []Result{{Name: "ok", Status: StatusOk}},
fail: []Result{{Name: "fail", Status: StatusErr}},
gitCommands: []string{
"git status --short",
"git diff --name-only --cached --diff-filter=ACMR",
"git add .*README.md",
"git apply -v --whitespace=nowarn --recount --unidiff-zero ",
"git stash list",
},
},
{
name: "pre-commit hook with stage_fixed under root",
hookName: "pre-commit",
Expand Down Expand Up @@ -737,6 +769,7 @@ func TestRunAll(t *testing.T) {
HookName: tt.hookName,
GitArgs: tt.args,
ResultChan: resultChan,
Force: tt.force,
},
executor: executor,
}
Expand Down

0 comments on commit 4349372

Please sign in to comment.