Skip to content

Commit

Permalink
fix race condition in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Apr 24, 2023
1 parent 023605a commit 78ec60b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/dbsync/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ func TestFileProcessHappyPath(t *testing.T) {
Md5Checksum: [][]byte{sum[:]},
})
for {
if _, ok := syncer.pendingFiles["f1"]; ok {
syncer.mtx.RLock()
_, ok := syncer.pendingFiles["f1"]
syncer.mtx.RUnlock()
if ok {
break
}
}
Expand All @@ -105,7 +108,10 @@ func TestFileProcessTimeoutReprocess(t *testing.T) {
Md5Checksum: [][]byte{sum[:]},
})
for {
if _, ok := syncer.pendingFiles["f1"]; ok {
syncer.mtx.RLock()
_, ok := syncer.pendingFiles["f1"]
syncer.mtx.RUnlock()
if ok {
break
}
}
Expand Down

0 comments on commit 78ec60b

Please sign in to comment.