Skip to content

Commit

Permalink
fix(policy): unit test inline git config (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrynhard authored Oct 15, 2018
1 parent e439cd7 commit 954c003
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions pkg/policy/conventionalcommit/conventionalcommit_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package conventionalcommit

import (
"fmt"
"io/ioutil"
"log"
"os"
Expand Down Expand Up @@ -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"}
Expand All @@ -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
Expand All @@ -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
}

0 comments on commit 954c003

Please sign in to comment.