Use pause/resume device to ensure TestConflictsDefault can run

This commit is contained in:
Jakob Borg 2015-11-17 13:32:57 +01:00
parent 9cf653d673
commit 37f866b47f
2 changed files with 26 additions and 0 deletions

View File

@ -281,6 +281,16 @@ func (p *Process) PostConfig(cfg config.Configuration) error {
return err
}
func (p *Process) PauseDevice(dev protocol.DeviceID) error {
_, err := p.Post("/rest/system/pause?device="+dev.String(), nil)
return err
}
func (p *Process) ResumeDevice(dev protocol.DeviceID) error {
_, err := p.Post("/rest/system/resume?device="+dev.String(), nil)
return err
}
func InSync(folder string, ps ...*Process) bool {
for _, p := range ps {
p.eventMut.Lock()

View File

@ -80,6 +80,10 @@ func TestConflictsDefault(t *testing.T) {
log.Println("Introducing a conflict (simultaneous edit)...")
if err := sender.PauseDevice(receiver.ID()); err != nil {
t.Fatal(err)
}
fd, err = os.OpenFile("s1/testfile.txt", os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
t.Fatal(err)
@ -106,6 +110,10 @@ func TestConflictsDefault(t *testing.T) {
t.Fatal(err)
}
if err := sender.ResumeDevice(receiver.ID()); err != nil {
t.Fatal(err)
}
log.Println("Syncing...")
if err := sender.RescanDelay("default", 86400); err != nil {
@ -129,6 +137,10 @@ func TestConflictsDefault(t *testing.T) {
log.Println("Introducing a conflict (edit plus delete)...")
if err := sender.PauseDevice(receiver.ID()); err != nil {
t.Fatal(err)
}
err = os.Remove("s1/testfile.txt")
if err != nil {
t.Fatal(err)
@ -147,6 +159,10 @@ func TestConflictsDefault(t *testing.T) {
t.Fatal(err)
}
if err := sender.ResumeDevice(receiver.ID()); err != nil {
t.Fatal(err)
}
log.Println("Syncing...")
if err := sender.RescanDelay("default", 86400); err != nil {