juju: github.com/wallyworld/juju/api/base/testing Index | Files

package testing

import "github.com/wallyworld/juju/api/base/testing"


Package Files

apicaller.go patch.go

func APICallerWithBakery Uses

func APICallerWithBakery(caller base.APICallCloser, discharger base.MacaroonDischarger) *apiCallerWithBakery

APICallerWithBakery returns an api caller with a bakery client which uses the specified discharge acquirer.

func NotifyingAPICaller Uses

func NotifyingAPICaller(c *gc.C, called chan<- struct{}, caller base.APICaller) base.APICaller

NotifyingAPICaller returns an APICaller implementation which sends a message on the given channel every time it receives a call.

func PatchFacadeCall Uses

func PatchFacadeCall(p Patcher, caller *base.FacadeCaller, f func(request string, params, response interface{}) error)

PatchFacadeCall patches the provided FacadeCaller such that the FacadeCall method calls are diverted to the provided function.

type APICall Uses

type APICall struct {
    // If Check is non-nil, all other fields will be ignored and Check
    // will be called to check the call.
    Check func(objType string, version int, id, request string, params, response interface{}) error

    // Facade holds the expected call facade. If it's empty,
    // any facade will be accepted.
    Facade string

    // Version holds the expected call version. If it's zero,
    // any version will be accepted unless VersionIsZero is true.
    Version int

    // VersionIsZero holds whether the version is expected to be zero.
    VersionIsZero bool

    // Id holds the expected call id. If it's empty, any id will be
    // accepted unless IdIsEmpty is true.
    Id  string

    // IdIsEmpty holds whether the call id is expected to be empty.
    IdIsEmpty bool

    // Method holds the expected method.
    Method string

    // Args holds the expected value of the call's argument.
    Args interface{}

    // Results is assigned to the result parameter of the call on return.
    Results interface{}

    // Error is returned from the call.
    Error error

APICall describes an expected API call.

type APICallerFunc Uses

type APICallerFunc func(objType string, version int, id, request string, params, response interface{}) error

APICallerFunc is a function type that implements APICaller. The only method that actually does anything is APICall itself which calls the function. The other methods are just stubs.

func (APICallerFunc) APICall Uses

func (f APICallerFunc) APICall(objType string, version int, id, request string, params, response interface{}) error

func (APICallerFunc) BakeryClient Uses

func (APICallerFunc) BakeryClient() base.MacaroonDischarger

func (APICallerFunc) BestFacadeVersion Uses

func (APICallerFunc) BestFacadeVersion(facade string) int

func (APICallerFunc) Close Uses

func (APICallerFunc) Close() error

func (APICallerFunc) ConnectControllerStream Uses

func (APICallerFunc) ConnectControllerStream(path string, attrs url.Values, headers http.Header) (base.Stream, error)

func (APICallerFunc) ConnectStream Uses

func (APICallerFunc) ConnectStream(path string, attrs url.Values) (base.Stream, error)

func (APICallerFunc) Context Uses

func (APICallerFunc) Context() context.Context

func (APICallerFunc) HTTPClient Uses

func (APICallerFunc) HTTPClient() (*httprequest.Client, error)

func (APICallerFunc) ModelTag Uses

func (APICallerFunc) ModelTag() (names.ModelTag, bool)

type BestVersionCaller Uses

type BestVersionCaller struct {
    BestVersion int

BestVersionCaller is an APICallerFunc that has a particular best version.

func (BestVersionCaller) BestFacadeVersion Uses

func (c BestVersionCaller) BestFacadeVersion(facade string) int

type CallChecker Uses

type CallChecker struct {

    // CallCount records the current call count.
    CallCount int

CallChecker is an APICaller implementation that checks calls as they are made.

func APICallChecker Uses

func APICallChecker(c *gc.C, calls ...APICall) *CallChecker

APICallChecker returns an APICaller implementation that checks API calls. Each element of calls corresponds to an expected API call. If more calls are made than there are elements, they will not be checked - check the value of the Count field to ensure that the expected number of calls have been made.

Note that the returned value is not thread-safe - do not use it if the client is making concurrent calls.

type Patcher Uses

type Patcher interface {
    PatchValue(dest, value interface{})

type StubFacadeCaller Uses

type StubFacadeCaller struct {
    // Stub is the raw stub used to track calls and errors.
    Stub *testing.Stub
    // These control the values returned by the stub's methods.
    FacadeCallFn         func(name string, params, response interface{}) error
    ReturnName           string
    ReturnBestAPIVersion int
    ReturnRawAPICaller   base.APICaller

StubFacadeCaller is a testing stub implementation of api/base.FacadeCaller.

func (*StubFacadeCaller) BestAPIVersion Uses

func (s *StubFacadeCaller) BestAPIVersion() int

BestAPIVersion implements api/base.FacadeCaller.

func (*StubFacadeCaller) FacadeCall Uses

func (s *StubFacadeCaller) FacadeCall(request string, params, response interface{}) error

FacadeCall implements api/base.FacadeCaller.

func (*StubFacadeCaller) Name Uses

func (s *StubFacadeCaller) Name() string

Name implements api/base.FacadeCaller.

func (*StubFacadeCaller) RawAPICaller Uses

func (s *StubFacadeCaller) RawAPICaller() base.APICaller

RawAPICaller implements api/base.FacadeCaller.

Package testing imports 11 packages (graph). Updated 2020-08-06. Refresh now. Tools for package owners.