github.com/Pankov404/juju@v0.0.0-20150703034450-be266991dceb/worker/uniter/runner/jujuc/testing/relationhook.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/juju/worker/uniter/runner/jujuc" 8 ) 9 10 // RelationHook holds the values for the hook context. 11 type RelationHook struct { 12 HookRelation jujuc.ContextRelation 13 RemoteUnitName string 14 } 15 16 // Reset clears the RelationHook's data. 17 func (rh *RelationHook) Reset() { 18 rh.HookRelation = nil 19 rh.RemoteUnitName = "" 20 } 21 22 // ContextRelationHook is a test double for jujuc.RelationHookContext. 23 type ContextRelationHook struct { 24 contextBase 25 info *RelationHook 26 } 27 28 // HookRelation implements jujuc.RelationHookContext. 29 func (c *ContextRelationHook) HookRelation() (jujuc.ContextRelation, bool) { 30 c.stub.AddCall("HookRelation") 31 c.stub.NextErr() 32 33 return c.info.HookRelation, c.info.HookRelation != nil 34 } 35 36 // RemoteUnitName implements jujuc.RelationHookContext. 37 func (c *ContextRelationHook) RemoteUnitName() (string, bool) { 38 c.stub.AddCall("RemoteUnitName") 39 c.stub.NextErr() 40 41 return c.info.RemoteUnitName, c.info.RemoteUnitName != "" 42 }