mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 01:04:14 +00:00
lib/model: Prevent test deadlock (#7110)
This commit is contained in:
parent
1d3b9876f6
commit
b8051fb37e
@ -1149,6 +1149,9 @@ func TestRequestLastFileProgress(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRequestIndexSenderPause(t *testing.T) {
|
func TestRequestIndexSenderPause(t *testing.T) {
|
||||||
|
done := make(chan struct{})
|
||||||
|
defer close(done)
|
||||||
|
|
||||||
m, fc, fcfg := setupModelWithConnection()
|
m, fc, fcfg := setupModelWithConnection()
|
||||||
tfs := fcfg.Filesystem()
|
tfs := fcfg.Filesystem()
|
||||||
defer cleanupModelAndRemoveDir(m, tfs.URI())
|
defer cleanupModelAndRemoveDir(m, tfs.URI())
|
||||||
@ -1156,7 +1159,10 @@ func TestRequestIndexSenderPause(t *testing.T) {
|
|||||||
indexChan := make(chan []protocol.FileInfo)
|
indexChan := make(chan []protocol.FileInfo)
|
||||||
fc.mut.Lock()
|
fc.mut.Lock()
|
||||||
fc.indexFn = func(_ context.Context, folder string, fs []protocol.FileInfo) {
|
fc.indexFn = func(_ context.Context, folder string, fs []protocol.FileInfo) {
|
||||||
indexChan <- fs
|
select {
|
||||||
|
case indexChan <- fs:
|
||||||
|
case <-done:
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fc.mut.Unlock()
|
fc.mut.Unlock()
|
||||||
|
|
||||||
@ -1167,7 +1173,6 @@ func TestRequestIndexSenderPause(t *testing.T) {
|
|||||||
localIndexUpdate(m, fcfg.ID, files)
|
localIndexUpdate(m, fcfg.ID, files)
|
||||||
select {
|
select {
|
||||||
case <-time.After(5 * time.Second):
|
case <-time.After(5 * time.Second):
|
||||||
l.Infoln("timeout")
|
|
||||||
t.Fatal("timed out before receiving index")
|
t.Fatal("timed out before receiving index")
|
||||||
case <-indexChan:
|
case <-indexChan:
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user