mock

package
v1.11.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mock encapsulates mocks for testing GCE provider functionality. These methods are used to override the mock objects' methods in order to intercept the standard processing and to add custom logic for test purposes.

// Example usage:

cloud := cloud.NewMockGCE() cloud.MockTargetPools.AddInstanceHook = mock.AddInstanceHook

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInstanceHook

func AddInstanceHook(ctx context.Context, key *meta.Key, req *ga.TargetPoolsAddInstanceRequest, m *cloud.MockTargetPools) error

AddInstanceHook mocks adding a Instance to MockTargetPools

func AddInstancesHook

AddInstancesHook mocks adding instances from an InstanceGroup

func DeleteAddressesInternalErrHook

func DeleteAddressesInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockAddresses) (bool, error)

DeleteAddressesInternalErrHook mocks delete address and returns an internal server error.

func DeleteAddressesNotFoundErrHook

func DeleteAddressesNotFoundErrHook(ctx context.Context, key *meta.Key, m *cloud.MockAddresses) (bool, error)

DeleteAddressesNotFoundErrHook mocks deleting network address and returns a not found error.

func DeleteFirewallsUnauthorizedErrHook

func DeleteFirewallsUnauthorizedErrHook(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls) (bool, error)

DeleteFirewallsUnauthorizedErrHook mocks firewall deletion. A forbidden error will be thrown as return.

func GetAddressesInternalErrHook

func GetAddressesInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockAddresses) (bool, *ga.Address, error)

GetAddressesInternalErrHook mocks getting network address and returns an internal server error.

func GetFirewallsUnauthorizedErrHook

func GetFirewallsUnauthorizedErrHook(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls) (bool, *ga.Firewall, error)

GetFirewallsUnauthorizedErrHook mocks firewall information retrival. A forbidden error will be thrown as return.

func GetForwardingRulesInternalErrHook

func GetForwardingRulesInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockForwardingRules) (bool, *ga.ForwardingRule, error)

GetForwardingRulesInternalErrHook mocks getting forwarding rules and returns an internal server error.

func GetHTTPHealthChecksInternalErrHook

func GetHTTPHealthChecksInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockHttpHealthChecks) (bool, *ga.HttpHealthCheck, error)

GetHTTPHealthChecksInternalErrHook mocks getting http health check and returns an internal server error.

func GetTargetPoolInternalErrHook

func GetTargetPoolInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockTargetPools) (bool, *ga.TargetPool, error)

GetTargetPoolInternalErrHook mocks getting target pool. It returns a internal server error.

func InsertAddressHook

func InsertAddressHook(ctx context.Context, key *meta.Key, obj *ga.Address, m *cloud.MockAddresses) (bool, error)

InsertAddressHook mocks inserting an Address.

func InsertAlphaAddressHook

func InsertAlphaAddressHook(ctx context.Context, key *meta.Key, obj *alpha.Address, m *cloud.MockAlphaAddresses) (bool, error)

InsertAlphaAddressHook mocks inserting an Address. Addresses are expected to default to Premium tier if no NetworkTier is specified.

func InsertAlphaFwdRuleHook

func InsertAlphaFwdRuleHook(ctx context.Context, key *meta.Key, obj *alpha.ForwardingRule, m *cloud.MockForwardingRules) (bool, error)

InsertAlphaFwdRuleHook mocks inserting an AlphaForwardingRule.

func InsertBetaAddressHook

func InsertBetaAddressHook(ctx context.Context, key *meta.Key, obj *beta.Address, m *cloud.MockAddresses) (bool, error)

InsertBetaAddressHook mocks inserting a BetaAddress.

func InsertBetaFwdRuleHook

func InsertBetaFwdRuleHook(ctx context.Context, key *meta.Key, obj *beta.ForwardingRule, m *cloud.MockForwardingRules) (bool, error)

InsertBetaFwdRuleHook mocks inserting a BetaForwardingRule.

func InsertFirewallsUnauthorizedErrHook

func InsertFirewallsUnauthorizedErrHook(ctx context.Context, key *meta.Key, obj *ga.Firewall, m *cloud.MockFirewalls) (bool, error)

InsertFirewallsUnauthorizedErrHook mocks firewall insertion. A forbidden error will be thrown as return.

func InsertForwardingRulesInternalErrHook

func InsertForwardingRulesInternalErrHook(ctx context.Context, key *meta.Key, obj *ga.ForwardingRule, m *cloud.MockForwardingRules) (bool, error)

InsertForwardingRulesInternalErrHook mocks getting forwarding rule and returns an internal server error.

func InsertFwdRuleHook

func InsertFwdRuleHook(ctx context.Context, key *meta.Key, obj *ga.ForwardingRule, m *cloud.MockForwardingRules) (bool, error)

InsertFwdRuleHook mocks inserting a ForwardingRule. ForwardingRules are expected to default to Premium tier if no NetworkTier is specified.

func InsertTargetPoolsInternalErrHook

func InsertTargetPoolsInternalErrHook(ctx context.Context, key *meta.Key, obj *ga.TargetPool, m *cloud.MockTargetPools) (bool, error)

InsertTargetPoolsInternalErrHook mocks getting target pool and returns an internal server error.

func ListInstancesHook

ListInstancesHook mocks listing instances from an InstanceGroup

func RemoveInstanceHook

func RemoveInstanceHook(ctx context.Context, key *meta.Key, req *ga.TargetPoolsRemoveInstanceRequest, m *cloud.MockTargetPools) error

RemoveInstanceHook mocks removing a Instance from MockTargetPools

func RemoveInstancesHook

RemoveInstancesHook mocks removing instances from an InstanceGroup

func UpdateFirewallHook

func UpdateFirewallHook(ctx context.Context, key *meta.Key, obj *ga.Firewall, m *cloud.MockFirewalls) error

UpdateFirewallHook defines the hook for updating a Firewall. It replaces the object with the same key in the mock with the updated object.

func UpdateFirewallsUnauthorizedErrHook

func UpdateFirewallsUnauthorizedErrHook(ctx context.Context, key *meta.Key, obj *ga.Firewall, m *cloud.MockFirewalls) error

UpdateFirewallsUnauthorizedErrHook mocks firewall updating. A forbidden error will be thrown as return.

func UpdateHealthCheckHook

func UpdateHealthCheckHook(ctx context.Context, key *meta.Key, obj *ga.HealthCheck, m *cloud.MockHealthChecks) error

UpdateHealthCheckHook defines the hook for updating a HealthCheck. It replaces the object with the same key in the mock with the updated object.

func UpdateRegionBackendServiceHook

func UpdateRegionBackendServiceHook(ctx context.Context, key *meta.Key, obj *ga.BackendService, m *cloud.MockRegionBackendServices) error

UpdateRegionBackendServiceHook defines the hook for updating a Region BackendsService. It replaces the object with the same key in the mock with the updated object.

Types

type AddressAttributes

type AddressAttributes struct {
	IPCounter int // Used to assign Addresses with no IP a unique IP address
}

AddressAttributes maps from Address key to a map of Instances

type InstanceGroupAttributes

type InstanceGroupAttributes struct {
	InstanceMap map[meta.Key]map[string]*ga.InstanceWithNamedPorts
	Lock        *sync.Mutex
}

InstanceGroupAttributes maps from InstanceGroup key to a map of Instances

func (*InstanceGroupAttributes) AddInstances

func (igAttrs *InstanceGroupAttributes) AddInstances(key *meta.Key, instanceRefs []*ga.InstanceReference) error

AddInstances adds a list of Instances passed by InstanceReference

func (*InstanceGroupAttributes) List

func (igAttrs *InstanceGroupAttributes) List(key *meta.Key) []*ga.InstanceWithNamedPorts

List gets a list of InstanceWithNamedPorts

func (*InstanceGroupAttributes) RemoveInstances

func (igAttrs *InstanceGroupAttributes) RemoveInstances(key *meta.Key, instanceRefs []*ga.InstanceReference) error

RemoveInstances removes a list of Instances passed by InstanceReference

Jump to

Keyboard shortcuts

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