Defer unlock for testing daemon

Make sure we use defer when unlocking the daemon during testing.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2017-08-16 16:29:43 -04:00
parent 73ac66eecf
commit bfd62ceba9

View File

@ -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")
}
@ -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")
}
@ -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")
}
@ -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")
}