github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/uniter/runner/jujuc/testing/instance.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package testing 5 6 import ( 7 "github.com/juju/errors" 8 9 "github.com/juju/juju/worker/uniter/runner/jujuc" 10 ) 11 12 // Instance holds the values for the hook context. 13 type Instance struct { 14 AvailabilityZone string 15 RebootPriority *jujuc.RebootPriority 16 } 17 18 // ContextInstance is a test double for jujuc.ContextInstance. 19 type ContextInstance struct { 20 contextBase 21 info *Instance 22 } 23 24 // AvailabilityZone implements jujuc.ContextInstance. 25 func (c *ContextInstance) AvailabilityZone() (string, error) { 26 c.stub.AddCall("AvailabilityZone") 27 28 return c.info.AvailabilityZone, c.stub.NextErr() 29 } 30 31 // RequestReboot implements jujuc.ContextInstance. 32 func (c *ContextInstance) RequestReboot(priority jujuc.RebootPriority) error { 33 c.stub.AddCall("RequestReboot", priority) 34 if err := c.stub.NextErr(); err != nil { 35 return errors.Trace(err) 36 } 37 38 c.info.RebootPriority = &priority 39 return nil 40 }