mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-31 22:11:51 +00:00
lib/model: Locking in the request test
This commit is contained in:
parent
913a85c571
commit
e4db86836b
@ -253,6 +253,8 @@ func (f *fakeConnection) Option(string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeConnection) Index(folder string, fs []protocol.FileInfo) error {
|
func (f *fakeConnection) Index(folder string, fs []protocol.FileInfo) error {
|
||||||
|
f.mut.Lock()
|
||||||
|
defer f.mut.Unlock()
|
||||||
if f.indexFn != nil {
|
if f.indexFn != nil {
|
||||||
f.indexFn(folder, fs)
|
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 {
|
func (f *fakeConnection) IndexUpdate(folder string, fs []protocol.FileInfo) error {
|
||||||
|
f.mut.Lock()
|
||||||
|
defer f.mut.Unlock()
|
||||||
if f.indexFn != nil {
|
if f.indexFn != nil {
|
||||||
f.indexFn(folder, fs)
|
f.indexFn(folder, fs)
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ func TestRequestSimple(t *testing.T) {
|
|||||||
// We listen for incoming index updates and trigger when we see one for
|
// We listen for incoming index updates and trigger when we see one for
|
||||||
// the expected test file.
|
// the expected test file.
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
|
fc.mut.Lock()
|
||||||
fc.indexFn = func(folder string, fs []protocol.FileInfo) {
|
fc.indexFn = func(folder string, fs []protocol.FileInfo) {
|
||||||
for _, f := range fs {
|
for _, f := range fs {
|
||||||
if f.Name == "testfile" {
|
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.
|
// Send an update for the test file, wait for it to sync and be reported back.
|
||||||
contents := []byte("test file contents\n")
|
contents := []byte("test file contents\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user