diff --git a/lib/model/model_test.go b/lib/model/model_test.go index 7deb50c3..c5b235fb 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 c5236afc..331d3d6a 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")