mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
Fix race conditions in model tests
This commit is contained in:
parent
cc1387ec0c
commit
368cd44558
@ -445,11 +445,18 @@ func TestDeregisterOnFailInCopy(t *testing.T) {
|
|||||||
finisherChan <- state
|
finisherChan <- state
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
if state.fd != nil {
|
state.mut.Lock()
|
||||||
|
stateFd := state.fd
|
||||||
|
state.mut.Unlock()
|
||||||
|
if stateFd != nil {
|
||||||
t.Fatal("File not closed?")
|
t.Fatal("File not closed?")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(p.progressEmitter.registry) != 0 || len(p.queue.progress) != 0 || len(p.queue.queued) != 0 {
|
p.queue.mut.Lock()
|
||||||
|
lenQProgr := len(p.queue.progress)
|
||||||
|
lenQQueued := len(p.queue.queued)
|
||||||
|
p.queue.mut.Unlock()
|
||||||
|
if len(p.progressEmitter.registry) != 0 || lenQProgr != 0 || lenQQueued != 0 {
|
||||||
t.Fatal("Still registered", len(p.progressEmitter.registry), len(p.queue.progress), len(p.queue.queued))
|
t.Fatal("Still registered", len(p.progressEmitter.registry), len(p.queue.progress), len(p.queue.queued))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,7 +464,11 @@ func TestDeregisterOnFailInCopy(t *testing.T) {
|
|||||||
finisherChan <- state
|
finisherChan <- state
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
if len(p.progressEmitter.registry) != 0 || len(p.queue.progress) != 0 || len(p.queue.queued) != 0 {
|
p.queue.mut.Lock()
|
||||||
|
lenQProgr = len(p.queue.progress)
|
||||||
|
lenQQueued = len(p.queue.queued)
|
||||||
|
p.queue.mut.Unlock()
|
||||||
|
if len(p.progressEmitter.registry) != 0 || lenQProgr != 0 || lenQQueued != 0 {
|
||||||
t.Fatal("Still registered")
|
t.Fatal("Still registered")
|
||||||
}
|
}
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
@ -527,12 +538,19 @@ func TestDeregisterOnFailInPull(t *testing.T) {
|
|||||||
finisherChan <- state
|
finisherChan <- state
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
if state.fd != nil {
|
state.mut.Lock()
|
||||||
|
stateFd := state.fd
|
||||||
|
state.mut.Unlock()
|
||||||
|
if stateFd != nil {
|
||||||
t.Fatal("File not closed?")
|
t.Fatal("File not closed?")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(p.progressEmitter.registry) != 0 || len(p.queue.progress) != 0 || len(p.queue.queued) != 0 {
|
p.queue.mut.Lock()
|
||||||
t.Fatal("Still registered", len(p.progressEmitter.registry), len(p.queue.progress), len(p.queue.queued))
|
lenQProgr := len(p.queue.progress)
|
||||||
|
lenQQueued := len(p.queue.queued)
|
||||||
|
p.queue.mut.Unlock()
|
||||||
|
if len(p.progressEmitter.registry) != 0 || lenQProgr != 0 || lenQQueued != 0 {
|
||||||
|
t.Fatal("Still registered", len(p.progressEmitter.registry), lenQProgr, lenQQueued)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doing it again should have no effect
|
// Doing it again should have no effect
|
||||||
|
Loading…
Reference in New Issue
Block a user