github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/api/usermanager/export_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package usermanager
     5  
     6  import (
     7  	"github.com/juju/juju/api/base/testing"
     8  )
     9  
    10  // PatchResponses changes the internal FacadeCaller to one that lets you return
    11  // canned results. The responseFunc will get the 'response' interface object,
    12  // and can set attributes of it to fix the response to the caller.
    13  // It can also return an error to have the FacadeCall return an error.
    14  // The function returned by PatchResponses is a cleanup function that returns
    15  // the client to its original state.
    16  func PatchResponses(p testing.Patcher, client *Client, responseFunc func(interface{}) error) {
    17  	testing.PatchFacadeCall(p, &client.facade, func(request string, params, response interface{}) error {
    18  		return responseFunc(response)
    19  	})
    20  }