From e3bbf293e2ea402cc723205e35956911958085eb Mon Sep 17 00:00:00 2001 From: Dustin Decker Date: Mon, 6 Jun 2022 17:20:27 -0700 Subject: [PATCH] Fix NPD on mutex (#609) * Fix NPD on mutex * fix test --- pkg/sources/github/github.go | 2 +- pkg/sources/github/github_test.go | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/pkg/sources/github/github.go b/pkg/sources/github/github.go index 7866e9e8..b2fc1f27 100644 --- a/pkg/sources/github/github.go +++ b/pkg/sources/github/github.go @@ -51,7 +51,7 @@ type Source struct { conn *sourcespb.GitHub jobSem *semaphore.Weighted resumeInfoSlice []string - resumeInfoMutex *sync.Mutex + resumeInfoMutex sync.Mutex sources.Progress } diff --git a/pkg/sources/github/github_test.go b/pkg/sources/github/github_test.go index a73f60fc..0db9a527 100644 --- a/pkg/sources/github/github_test.go +++ b/pkg/sources/github/github_test.go @@ -12,7 +12,6 @@ import ( "reflect" "sort" "strconv" - "sync" "testing" "time" @@ -362,9 +361,8 @@ func Test_setProgressCompleteWithRepo(t *testing.T) { logger := logrus.New() logger.Out = io.Discard s := &Source{ - repos: []string{}, - log: logger.WithField("no", "output"), - resumeInfoMutex: &sync.Mutex{}, + repos: []string{}, + log: logger.WithField("no", "output"), } for _, tt := range tests { @@ -402,9 +400,8 @@ func Test_removeRepoFromResumeInfo(t *testing.T) { logger := logrus.New() logger.Out = io.Discard s := &Source{ - repos: []string{}, - log: logger.WithField("no", "output"), - resumeInfoMutex: &sync.Mutex{}, + repos: []string{}, + log: logger.WithField("no", "output"), } for _, tt := range tests { @@ -434,9 +431,8 @@ func Test_encodeResumeInfo(t *testing.T) { logger := logrus.New() logger.Out = io.Discard s := &Source{ - repos: []string{}, - log: logger.WithField("no", "output"), - resumeInfoMutex: &sync.Mutex{}, + repos: []string{}, + log: logger.WithField("no", "output"), } for _, tt := range tests { @@ -514,8 +510,7 @@ func Test_filterReposToResume(t *testing.T) { for name, tt := range tests { s := &Source{ - repos: startingRepos, - resumeInfoMutex: &sync.Mutex{}, + repos: startingRepos, } gotProgressOffsetCount := s.filterReposToResume(tt.resumeInfo)