github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/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, bool) { 26 c.stub.AddCall("AvailabilityZone") 27 c.stub.NextErr() 28 29 return c.info.AvailabilityZone, true 30 } 31 32 // RequestReboot implements jujuc.ContextInstance. 33 func (c *ContextInstance) RequestReboot(priority jujuc.RebootPriority) error { 34 c.stub.AddCall("RequestReboot", priority) 35 if err := c.stub.NextErr(); err != nil { 36 return errors.Trace(err) 37 } 38 39 c.info.RebootPriority = &priority 40 return nil 41 }