github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/api/backups/export_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package backups 5 6 import ( 7 "github.com/juju/juju/api/base" 8 ) 9 10 // ExposeFacade returns the client's underlying FacadeCaller. 11 func ExposeFacade(c *Client) base.FacadeCaller { 12 return c.facade 13 } 14 15 // PatchClientFacadeCall changes the internal FacadeCaller to one that lets 16 // you mock out the FacadeCall method. The function returned by 17 // PatchClientFacadeCall is a cleanup function that returns the client to its 18 // original state. 19 func PatchClientFacadeCall(c *Client, mockCall func(request string, params interface{}, response interface{}) error) func() { 20 orig := c.facade 21 c.facade = &resultCaller{mockCall} 22 return func() { 23 c.facade = orig 24 } 25 } 26 27 type resultCaller struct { 28 mockCall func(request string, params interface{}, response interface{}) error 29 } 30 31 func (f *resultCaller) FacadeCall(request string, params, response interface{}) error { 32 return f.mockCall(request, params, response) 33 } 34 35 func (f *resultCaller) Name() string { 36 return "" 37 } 38 39 func (f *resultCaller) BestAPIVersion() int { 40 return 0 41 } 42 43 func (f *resultCaller) RawAPICaller() base.APICaller { 44 return nil 45 }