aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-06-04 23:29:54 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-06-05 12:23:19 +0200
commit48b44e1ce06df8ab8a8571866e2cc658012103a2 (patch)
treeb1d2b70d05326fa27d435b156457f4a74c0bcb2c /pkg
parent2b2857bd2191458a131689502224abfe9cdd7a4a (diff)
.golangci.yml: reenable dupl checker
At some point it was enabled, but then somehow got disabled. Re-enable and fix some regressions.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/vcs/git_repo_test.go72
1 files changed, 23 insertions, 49 deletions
diff --git a/pkg/vcs/git_repo_test.go b/pkg/vcs/git_repo_test.go
index 2e768a72d..2bb8570d1 100644
--- a/pkg/vcs/git_repo_test.go
+++ b/pkg/vcs/git_repo_test.go
@@ -315,10 +315,29 @@ func TestBisect(t *testing.T) {
commits = append(commits, com.Hash)
t.Logf("%v %v", com.Hash, com.Title)
}
+ type predFunc func() (BisectResult, error)
type Test struct {
- pred func() (BisectResult, error)
+ pred predFunc
result []string
}
+ makePred := func(res1, res2, res3 BisectResult) predFunc {
+ return func() (BisectResult, error) {
+ current, err := repo.repo.HeadCommit()
+ if err != nil {
+ t.Fatal(err)
+ }
+ switch current.Hash {
+ case commits[1]:
+ return res1, nil
+ case commits[2]:
+ return res2, nil
+ case commits[3]:
+ return res3, nil
+ default:
+ return 0, fmt.Errorf("unknown commit %v", current.Hash)
+ }
+ }
+ }
tests := []Test{
{
// All are bad.
@@ -343,62 +362,17 @@ func TestBisect(t *testing.T) {
},
{
// Some are skipped.
- func() (BisectResult, error) {
- current, err := repo.repo.HeadCommit()
- if err != nil {
- t.Fatal(err)
- }
- switch current.Hash {
- case commits[1]:
- return BisectSkip, nil
- case commits[2]:
- return BisectSkip, nil
- case commits[3]:
- return BisectGood, nil
- default:
- return 0, fmt.Errorf("unknown commit %v", current.Hash)
- }
- },
+ makePred(BisectSkip, BisectSkip, BisectGood),
[]string{commits[4]},
},
{
// Some are skipped.
- func() (BisectResult, error) {
- current, err := repo.repo.HeadCommit()
- if err != nil {
- t.Fatal(err)
- }
- switch current.Hash {
- case commits[1]:
- return BisectGood, nil
- case commits[2]:
- return BisectSkip, nil
- case commits[3]:
- return BisectBad, nil
- default:
- return 0, fmt.Errorf("unknown commit %v", current.Hash)
- }
- },
+ makePred(BisectGood, BisectSkip, BisectBad),
[]string{commits[2], commits[3]},
},
{
// Some are skipped.
- func() (BisectResult, error) {
- current, err := repo.repo.HeadCommit()
- if err != nil {
- t.Fatal(err)
- }
- switch current.Hash {
- case commits[1]:
- return BisectSkip, nil
- case commits[2]:
- return BisectSkip, nil
- case commits[3]:
- return BisectGood, nil
- default:
- return 0, fmt.Errorf("unknown commit %v", current.Hash)
- }
- },
+ makePred(BisectSkip, BisectSkip, BisectGood),
[]string{commits[4]},
},
}