Refactored integration tests
Added internal/rc to remote control a Syncthing process and made the "awaiting sync" determination reliable.
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestDelayScan(t *testing.T) {
|
||||
func TestRescanWithDelay(t *testing.T) {
|
||||
log.Println("Cleaning...")
|
||||
err := removeAll("s1", "h1/index*")
|
||||
if err != nil {
|
||||
@@ -36,30 +36,8 @@ func TestDelayScan(t *testing.T) {
|
||||
}
|
||||
|
||||
log.Println("Starting up...")
|
||||
st := syncthingProcess{ // id1
|
||||
instance: "1",
|
||||
argv: []string{"-home", "h1"},
|
||||
port: 8081,
|
||||
apiKey: apiKey,
|
||||
}
|
||||
err = st.start()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for one scan to succeed, or up to 20 seconds...
|
||||
// This is to let startup, UPnP etc complete.
|
||||
for i := 0; i < 20; i++ {
|
||||
err := st.rescan("default")
|
||||
if err != nil {
|
||||
time.Sleep(time.Second)
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
// Wait for UPnP and stuff
|
||||
time.Sleep(10 * time.Second)
|
||||
st := startInstance(t, 1)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
log.Println("Starting scans...")
|
||||
@@ -68,7 +46,7 @@ func TestDelayScan(t *testing.T) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
err := st.rescanNext("default", time.Duration(1)*time.Second)
|
||||
err := st.RescanDelay("default", 1)
|
||||
log.Println(j)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -84,8 +62,5 @@ func TestDelayScan(t *testing.T) {
|
||||
// This is where the real test is currently, since stop() checks for data
|
||||
// race output in the log.
|
||||
log.Println("Stopping...")
|
||||
_, err = st.stop()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
checkedStop(t, st)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user