fake

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppGUIDRequiredError

func AppGUIDRequiredError() error

AppGUIDRequiredError returns error for when app GUID is missing from bind request.

func AsyncRequiredError

func AsyncRequiredError() error

AsyncRequiredError returns error for required asynchronous operations.

func NewFakeClientFunc

func NewFakeClientFunc(config FakeClientConfiguration) v2.CreateFunc

NewFakeClientFunc returns a v2.CreateFunc that returns a FakeClient with the given FakeClientConfiguration. It is useful for injecting the FakeClient in code that uses the v2.CreateFunc interface.

func ReturnFakeClientFunc

func ReturnFakeClientFunc(c *FakeClient) v2.CreateFunc

ReturnFakeClientFunc returns a v2.CreateFunc that returns the given FakeClient.

func UnexpectedActionError

func UnexpectedActionError() error

UnexpectedActionError returns an error message when an action is not found in the FakeClient's action array.

Types

type Action

type Action struct {
	Type    ActionType
	Request interface{}
}

Action is a record of a method call on the FakeClient.

type ActionType

type ActionType string

ActionType is a typedef over the set of actions that can be taken on a FakeClient.

const (
	GetCatalog               ActionType = "GetCatalog"
	ProvisionInstance        ActionType = "ProvisionInstance"
	UpdateInstance           ActionType = "UpdateInstance"
	DeprovisionInstance      ActionType = "DeprovisionInstance"
	PollLastOperation        ActionType = "PollLastOperation"
	PollBindingLastOperation ActionType = "PollBindingLastOperation"
	Bind                     ActionType = "Bind"
	Unbind                   ActionType = "Unbind"
	GetBinding               ActionType = "GetBinding"
)

These are the set of actions that can be taken on a FakeClient.

type BindReaction

type BindReaction struct {
	Response *v2.BindResponse
	Error    error
}

type BindReactionInterface

type BindReactionInterface interface {
	// contains filtered or unexported methods
}

BindReactionInterface defines the reaction to Bind requests.

type CatalogReaction

type CatalogReaction struct {
	Response *v2.CatalogResponse
	Error    error
}

type CatalogReactionInterface

type CatalogReactionInterface interface {
	// contains filtered or unexported methods
}

CatalogReactionInterface defines the reaction to GetCatalog requests.

type DeprovisionReaction

type DeprovisionReaction struct {
	Response *v2.DeprovisionResponse
	Error    error
}

type DeprovisionReactionInterface

type DeprovisionReactionInterface interface {
	// contains filtered or unexported methods
}

DeprovisionReactionInterface defines the reaction to DeprovisionInstance requests.

type DynamicBindReaction

type DynamicBindReaction func(*v2.BindRequest) (*v2.BindResponse, error)

type DynamicCatalogReaction

type DynamicCatalogReaction func() (*v2.CatalogResponse, error)

type DynamicDeprovisionReaction

type DynamicDeprovisionReaction func(*v2.DeprovisionRequest) (*v2.DeprovisionResponse, error)

type DynamicGetBindingReaction

type DynamicGetBindingReaction func() (*v2.GetBindingResponse, error)

type DynamicPollBindingLastOperationReaction

type DynamicPollBindingLastOperationReaction func(*v2.BindingLastOperationRequest) (*v2.LastOperationResponse, error)

type DynamicPollLastOperationReaction

type DynamicPollLastOperationReaction func(*v2.LastOperationRequest) (*v2.LastOperationResponse, error)

type DynamicProvisionReaction

type DynamicProvisionReaction func(*v2.ProvisionRequest) (*v2.ProvisionResponse, error)

type DynamicUnbindReaction

type DynamicUnbindReaction func(*v2.UnbindRequest) (*v2.UnbindResponse, error)

type DynamicUpdateInstanceReaction

type DynamicUpdateInstanceReaction func(*v2.UpdateInstanceRequest) (*v2.UpdateInstanceResponse, error)

type FakeClient

type FakeClient struct {
	CatalogReaction                  CatalogReactionInterface
	ProvisionReaction                ProvisionReactionInterface
	UpdateInstanceReaction           UpdateInstanceReactionInterface
	DeprovisionReaction              DeprovisionReactionInterface
	PollLastOperationReaction        PollLastOperationReactionInterface
	PollLastOperationReactions       map[v2.OperationKey]*PollLastOperationReaction
	PollBindingLastOperationReaction PollBindingLastOperationReactionInterface
	BindReaction                     BindReactionInterface
	UnbindReaction                   UnbindReactionInterface
	GetBindingReaction               GetBindingReactionInterface

	sync.Mutex
	// contains filtered or unexported fields
}

FakeClient is a fake implementation of the v2.Client interface. It records the actions that are taken on it and runs the appropriate reaction to those actions. If an action for which there is no reaction specified occurs, it returns an error. FakeClient is threadsafe.

func NewFakeClient

func NewFakeClient(config FakeClientConfiguration) *FakeClient

NewFakeClient returns a new fake Client with the given FakeClientConfiguration.

func (*FakeClient) Actions

func (c *FakeClient) Actions() []Action

Actions is a method defined on FakeClient that returns the actions taken on it.

func (*FakeClient) Bind

Bind implements the Client.Bind method on the FakeClient.

func (*FakeClient) DeprovisionInstance

func (c *FakeClient) DeprovisionInstance(r *v2.DeprovisionRequest, ctx context.Context) (*v2.DeprovisionResponse, error)

DeprovisionInstance implements the Client.DeprovisionInstance method on the FakeClient.

func (*FakeClient) GetBinding

GetBinding implements the Client.GetBinding method for the FakeClient.

func (*FakeClient) GetCatalog

func (c *FakeClient) GetCatalog(ctx context.Context) (*v2.CatalogResponse, error)

GetCatalog implements the Client.GetCatalog method for the FakeClient.

func (*FakeClient) PollBindingLastOperation

func (c *FakeClient) PollBindingLastOperation(r *v2.BindingLastOperationRequest, ctx context.Context) (*v2.LastOperationResponse, error)

PollBindingLastOperation implements the Client.PollBindingLastOperation method on the FakeClient.

func (*FakeClient) PollLastOperation

func (c *FakeClient) PollLastOperation(r *v2.LastOperationRequest, ctx context.Context) (*v2.LastOperationResponse, error)

PollLastOperation implements the Client.PollLastOperation method on the FakeClient.

func (*FakeClient) ProvisionInstance

func (c *FakeClient) ProvisionInstance(r *v2.ProvisionRequest, ctx context.Context) (*v2.ProvisionResponse, error)

ProvisionInstance implements the Client.ProvisionRequest method for the FakeClient.

func (*FakeClient) Unbind

Unbind implements the Client.Unbind method on the FakeClient.

func (*FakeClient) UpdateInstance

UpdateInstance implements the Client.UpdateInstance method for the FakeClient.

type FakeClientConfiguration

type FakeClientConfiguration struct {
	CatalogReaction                  CatalogReactionInterface
	ProvisionReaction                ProvisionReactionInterface
	UpdateInstanceReaction           UpdateInstanceReactionInterface
	DeprovisionReaction              DeprovisionReactionInterface
	PollLastOperationReaction        PollLastOperationReactionInterface
	PollLastOperationReactions       map[v2.OperationKey]*PollLastOperationReaction
	PollBindingLastOperationReaction PollBindingLastOperationReactionInterface
	BindReaction                     BindReactionInterface
	UnbindReaction                   UnbindReactionInterface
	GetBindingReaction               GetBindingReactionInterface
}

FakeClientConfiguration models the configuration of a FakeClient.

type GetBindingReaction

type GetBindingReaction struct {
	Response *v2.GetBindingResponse
	Error    error
}

type GetBindingReactionInterface

type GetBindingReactionInterface interface {
	// contains filtered or unexported methods
}

GetBindingReactionInterface defines the reaction to GetBinding requests.

type PollBindingLastOperationReaction

type PollBindingLastOperationReaction struct {
	Response *v2.LastOperationResponse
	Error    error
}

type PollBindingLastOperationReactionInterface

type PollBindingLastOperationReactionInterface interface {
	// contains filtered or unexported methods
}

PollBindingLastOperationReactionInterface defines the reaction to PollLastOperation requests.

type PollLastOperationReaction

type PollLastOperationReaction struct {
	Response *v2.LastOperationResponse
	Error    error
}

type PollLastOperationReactionInterface

type PollLastOperationReactionInterface interface {
	// contains filtered or unexported methods
}

PollLastOperationReactionInterface defines the reaction to PollLastOperation requests.

type ProvisionReaction

type ProvisionReaction struct {
	Response *v2.ProvisionResponse
	Error    error
}

type ProvisionReactionInterface

type ProvisionReactionInterface interface {
	// contains filtered or unexported methods
}

ProvisionReactionInterface defines the reaction to ProvisionInstance requests.

type UnbindReaction

type UnbindReaction struct {
	Response *v2.UnbindResponse
	Error    error
}

type UnbindReactionInterface

type UnbindReactionInterface interface {
	// contains filtered or unexported methods
}

UnbindReactionInterface defines the reaction to Unbind requests.

type UpdateInstanceReaction

type UpdateInstanceReaction struct {
	Response *v2.UpdateInstanceResponse
	Error    error
}

type UpdateInstanceReactionInterface

type UpdateInstanceReactionInterface interface {
	// contains filtered or unexported methods
}

UpdateInstanceReactionInterface defines the reaction to UpdateInstance requests.

Jump to

Keyboard shortcuts

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