testing

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2016 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckingAPICaller

func CheckingAPICaller(c *gc.C, args *CheckArgs, numCalls *int, err error) base.APICallCloser

CheckingAPICaller returns an APICallerFunc which can report the number of times its APICall() method was called (if numCalls is not nil), as well as check if any of the arguments passed to the APICall() method match the values given in args (if args itself is not nil, otherwise no arguments are checked). The final error result of the APICall() will be set to err.

func CheckingAPICallerMultiArgs

func CheckingAPICallerMultiArgs(c *gc.C, args []CheckArgs, numCalls *int, err error) base.APICallCloser

CheckingAPICallerMultiArgs checks each call against the indexed expected argument. Once expected arguments run out it doesn't check them. This is useful if your test continues to make calls after you have checked the ones you care about.

func NotifyingCheckingAPICaller

func NotifyingCheckingAPICaller(c *gc.C, args *CheckArgs, called chan struct{}, err error) base.APICaller

NotifyingCheckingAPICaller returns an APICallerFunc which sends a message on the channel "called" every time it recives a call, as well as check if any of the arguments passed to the APICall() method match the values given in args (if args itself is not nil, otherwise no arguments are checked). The final error result of the APICall() will be set to err.

func PatchFacadeCall

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.

Types

type APICallerFunc

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

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

func (APICallerFunc) BestFacadeVersion

func (APICallerFunc) BestFacadeVersion(facade string) int

func (APICallerFunc) Close

func (APICallerFunc) Close() error

func (APICallerFunc) ConnectStream

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

func (APICallerFunc) HTTPClient

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

func (APICallerFunc) ModelTag

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

type CheckArgs

type CheckArgs struct {
	Facade  string
	Version int
	Id      string
	Method  string
	Args    interface{}
	Results interface{}

	IdIsEmpty     bool
	VersionIsZero bool
}

CheckArgs holds the possible arguments to CheckingAPICaller(). Any fields non empty fields will be checked to match the arguments recieved by the APICall() method of the returned APICallerFunc. If Id is empty, but IdIsEmpty is true, the id argument is checked to be empty. The same applies to Version being empty, but if VersionIsZero set to true the version is checked to be 0.

type Patcher

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

type StubFacadeCaller

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

func (s *StubFacadeCaller) BestAPIVersion() int

BestAPIVersion implements api/base.FacadeCaller.

func (*StubFacadeCaller) FacadeCall

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

FacadeCall implements api/base.FacadeCaller.

func (*StubFacadeCaller) Name

func (s *StubFacadeCaller) Name() string

Name implements api/base.FacadeCaller.

func (*StubFacadeCaller) RawAPICaller

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

RawAPICaller implements api/base.FacadeCaller.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL