mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
Use pause/resume device to ensure TestConflictsDefault can run
This commit is contained in:
parent
9cf653d673
commit
37f866b47f
10
lib/rc/rc.go
10
lib/rc/rc.go
@ -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()
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user