-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(policy): unit test inline git config (#77)
- Loading branch information
1 parent
e439cd7
commit 954c003
Showing
1 changed file
with
5 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package conventionalcommit | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
|
@@ -76,11 +77,11 @@ func TestInvalidConventionalCommitPolicy(t *testing.T) { | |
func runCompliance() (*policy.Report, error) { | ||
g, err := git.NewGit() | ||
if err != nil { | ||
return nil, err | ||
return nil, fmt.Errorf("failed to open git: %v", err) | ||
} | ||
message, err := g.Message() | ||
if err != nil { | ||
return nil, err | ||
return nil, fmt.Errorf("failed to get commit message: %v", err) | ||
} | ||
c := &Conventional{} | ||
c.Types = []string{"type"} | ||
|
@@ -100,14 +101,6 @@ func initRepo() error { | |
if err != nil { | ||
return err | ||
} | ||
_, err = exec.Command("git", "config", "--global", "user.email", "'[email protected]'").Output() | ||
if err != nil { | ||
return err | ||
} | ||
_, err = exec.Command("git", "config", "--global", "user.name", "test").Output() | ||
if err != nil { | ||
return err | ||
} | ||
_, err = exec.Command("touch", "test").Output() | ||
if err != nil { | ||
return err | ||
|
@@ -118,13 +111,13 @@ func initRepo() error { | |
} | ||
|
||
func createValidCommit() error { | ||
_, err := exec.Command("git", "commit", "-m", "type(scope): description").Output() | ||
_, err := exec.Command("git", "-c", "user.name='test'", "-c", "user.email='[email protected]'", "commit", "-m", "type(scope): description").Output() | ||
|
||
return err | ||
} | ||
|
||
func createInvalidCommit() error { | ||
_, err := exec.Command("git", "commit", "-m", "invalid commit").Output() | ||
_, err := exec.Command("git", "-c", "user.name='test'", "-c", "user.email='[email protected]'", "commit", "-m", "invalid commit").Output() | ||
|
||
return err | ||
} |