Fix NPD on mutex (#609)

* Fix NPD on mutex

* fix test
This commit is contained in:
Dustin Decker
2022-06-06 17:20:27 -07:00
committed by GitHub
parent 9074006695
commit e3bbf293e2
2 changed files with 8 additions and 13 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ type Source struct {
conn *sourcespb.GitHub
jobSem *semaphore.Weighted
resumeInfoSlice []string
resumeInfoMutex *sync.Mutex
resumeInfoMutex sync.Mutex
sources.Progress
}
+7 -12
View File
@@ -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)