Adds Start tests

This commit is contained in:
Tai Groot 2021-05-16 23:59:09 -07:00
parent 3f10bbd46e
commit 15305985ee
Signed by: taigrr
GPG Key ID: D00C269A87614812

View File

@ -401,6 +401,38 @@ func TestShow(t *testing.T) {
}
func TestStart(t *testing.T) {
unit := "nginx"
userMode := false
if userString != "root" && userString != "system" {
userMode = true
unit = "syncthing"
}
opts := Options{UserMode: userMode}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
Stop(ctx, unit, opts)
for {
running, err := IsActive(ctx, unit, opts)
if err != nil {
t.Errorf("error asserting %s is up: %v", unit, err)
break
} else if !running {
break
}
}
err := Start(ctx, unit, opts)
if err != nil {
t.Errorf("error: %v", err)
}
for {
running, err := IsActive(ctx, unit, opts)
if err != nil {
t.Errorf("error asserting %s started: %v", unit, err)
break
} else if running {
break
}
}
}