From d4925443c8da54f678617fa19010a1ff726b491a Mon Sep 17 00:00:00 2001 From: zach rice Date: Wed, 6 Feb 2019 19:20:52 -0600 Subject: [PATCH] workin on tests --- gitleaks_test.go | 12 ++++++++---- main.go | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gitleaks_test.go b/gitleaks_test.go index c9b21c9f..b5acfde1 100644 --- a/gitleaks_test.go +++ b/gitleaks_test.go @@ -684,6 +684,7 @@ func TestAuditRepo(t *testing.T) { whiteListRepos = nil } skip := false + totalCommits = 0 // config paths if test.configPath != "" { os.Setenv("GITLEAKS_CONFIG", test.configPath) @@ -695,11 +696,14 @@ func TestAuditRepo(t *testing.T) { } if !skip { leaks, err = auditGitRepo(test.repo) - - if opts.Redact { - g.Assert(leaks[0].Offender).Equal("REDACTED") + if test.testOpts.Depth != 0 { + g.Assert(totalCommits).Equal(test.testOpts.Depth) + } else { + if opts.Redact { + g.Assert(leaks[0].Offender).Equal("REDACTED") + } + g.Assert(len(leaks)).Equal(test.numLeaks) } - g.Assert(len(leaks)).Equal(test.numLeaks) } }) }) diff --git a/main.go b/main.go index 0efe60a6..b7087483 100644 --- a/main.go +++ b/main.go @@ -72,7 +72,7 @@ type Options struct { CommitStop string `long:"commit-stop" description:"sha of commit to stop at"` Commit string `long:"commit" description:"sha of commit to investigate"` - Depth int `long:"depth" description:"maximum commit depth"` + Depth int64 `long:"depth" description:"maximum commit depth"` // local target option RepoPath string `long:"repo-path" description:"Path to repo"` @@ -509,7 +509,7 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak { err error repoName string leaks []Leak - commitCount int + commitCount int64 commitWg sync.WaitGroup mutex = &sync.Mutex{} semaphore chan bool