From 48b44e1ce06df8ab8a8571866e2cc658012103a2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 4 Jun 2020 23:29:54 +0200 Subject: .golangci.yml: reenable dupl checker At some point it was enabled, but then somehow got disabled. Re-enable and fix some regressions. --- pkg/vcs/git_repo_test.go | 72 ++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 49 deletions(-) (limited to 'pkg') 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]}, }, } -- cgit mrf-deployment