Skip to content

Commit

Permalink
Defer unlock for testing daemon
Browse files Browse the repository at this point in the history
Make sure we use defer when unlocking the daemon during testing.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
  • Loading branch information
crosbymichael committed Aug 16, 2017
1 parent 73ac66e commit bfd62ce
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (d *daemon) waitForStart(ctx context.Context) (*Client, error) {

func (d *daemon) Stop() error {
d.Lock()
d.Unlock()
defer d.Unlock()
if d.cmd == nil {
return errors.New("daemon is not running")
}
Expand All @@ -69,7 +69,7 @@ func (d *daemon) Stop() error {

func (d *daemon) Kill() error {
d.Lock()
d.Unlock()
defer d.Unlock()
if d.cmd == nil {
return errors.New("daemon is not running")
}
Expand All @@ -78,7 +78,7 @@ func (d *daemon) Kill() error {

func (d *daemon) Wait() error {
d.Lock()
d.Unlock()
defer d.Unlock()
if d.cmd == nil {
return errors.New("daemon is not running")
}
Expand All @@ -87,7 +87,7 @@ func (d *daemon) Wait() error {

func (d *daemon) Restart() error {
d.Lock()
d.Unlock()
defer d.Unlock()
if d.cmd == nil {
return errors.New("daemon is not running")
}
Expand Down

0 comments on commit bfd62ce

Please sign in to comment.