Skip to content

Commit

Permalink
Adds Start tests
Browse files Browse the repository at this point in the history
  • Loading branch information
taigrr committed May 17, 2021
1 parent 3f10bbd commit 1530598
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions systemctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

}

Expand Down

0 comments on commit 1530598

Please sign in to comment.