From e4db86836b13f60737381698776aaa3bcccabd62 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 30 Nov 2016 13:11:06 +0100 Subject: [PATCH] lib/model: Locking in the request test --- lib/model/model_test.go | 4 ++++ lib/model/requests_test.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/lib/model/model_test.go b/lib/model/model_test.go index 7deb50c30..c5b235fb6 100644 --- a/lib/model/model_test.go +++ b/lib/model/model_test.go @@ -253,6 +253,8 @@ func (f *fakeConnection) Option(string) string { } func (f *fakeConnection) Index(folder string, fs []protocol.FileInfo) error { + f.mut.Lock() + defer f.mut.Unlock() if f.indexFn != nil { f.indexFn(folder, fs) } @@ -260,6 +262,8 @@ func (f *fakeConnection) Index(folder string, fs []protocol.FileInfo) error { } func (f *fakeConnection) IndexUpdate(folder string, fs []protocol.FileInfo) error { + f.mut.Lock() + defer f.mut.Unlock() if f.indexFn != nil { f.indexFn(folder, fs) } diff --git a/lib/model/requests_test.go b/lib/model/requests_test.go index c5236afca..331d3d6af 100644 --- a/lib/model/requests_test.go +++ b/lib/model/requests_test.go @@ -29,6 +29,7 @@ func TestRequestSimple(t *testing.T) { // We listen for incoming index updates and trigger when we see one for // the expected test file. done := make(chan struct{}) + fc.mut.Lock() fc.indexFn = func(folder string, fs []protocol.FileInfo) { for _, f := range fs { if f.Name == "testfile" { @@ -37,6 +38,7 @@ func TestRequestSimple(t *testing.T) { } } } + fc.mut.Unlock() // Send an update for the test file, wait for it to sync and be reported back. contents := []byte("test file contents\n")