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 ¶
- func AddInstanceHook(ctx context.Context, key *meta.Key, req *ga.TargetPoolsAddInstanceRequest, ...) error
- func AddInstancesHook(ctx context.Context, key *meta.Key, req *ga.InstanceGroupsAddInstancesRequest, ...) error
- func DeleteAddressesInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockAddresses) (bool, error)
- func DeleteAddressesNotFoundErrHook(ctx context.Context, key *meta.Key, m *cloud.MockAddresses) (bool, error)
- func DeleteFirewallsUnauthorizedErrHook(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls) (bool, error)
- func GetAddressesInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockAddresses) (bool, *ga.Address, error)
- func GetFirewallsUnauthorizedErrHook(ctx context.Context, key *meta.Key, m *cloud.MockFirewalls) (bool, *ga.Firewall, error)
- func GetForwardingRulesInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockForwardingRules) (bool, *ga.ForwardingRule, error)
- func GetHTTPHealthChecksInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockHttpHealthChecks) (bool, *ga.HttpHealthCheck, error)
- func GetTargetPoolInternalErrHook(ctx context.Context, key *meta.Key, m *cloud.MockTargetPools) (bool, *ga.TargetPool, error)
- func InsertAddressHook(ctx context.Context, key *meta.Key, obj *ga.Address, m *cloud.MockAddresses) (bool, error)
- func InsertAlphaAddressHook(ctx context.Context, key *meta.Key, obj *alpha.Address, ...) (bool, error)
- func InsertAlphaFwdRuleHook(ctx context.Context, key *meta.Key, obj *alpha.ForwardingRule, ...) (bool, error)
- func InsertBetaAddressHook(ctx context.Context, key *meta.Key, obj *beta.Address, m *cloud.MockAddresses) (bool, error)
- func InsertBetaFwdRuleHook(ctx context.Context, key *meta.Key, obj *beta.ForwardingRule, ...) (bool, error)
- func InsertFirewallsUnauthorizedErrHook(ctx context.Context, key *meta.Key, obj *ga.Firewall, m *cloud.MockFirewalls) (bool, error)
- func InsertForwardingRulesInternalErrHook(ctx context.Context, key *meta.Key, obj *ga.ForwardingRule, ...) (bool, error)
- func InsertFwdRuleHook(ctx context.Context, key *meta.Key, obj *ga.ForwardingRule, ...) (bool, error)
- func InsertTargetPoolsInternalErrHook(ctx context.Context, key *meta.Key, obj *ga.TargetPool, ...) (bool, error)
- func ListInstancesHook(ctx context.Context, key *meta.Key, req *ga.InstanceGroupsListInstancesRequest, ...) ([]*ga.InstanceWithNamedPorts, error)
- func RemoveInstanceHook(ctx context.Context, key *meta.Key, req *ga.TargetPoolsRemoveInstanceRequest, ...) error
- func RemoveInstancesHook(ctx context.Context, key *meta.Key, ...) error
- func UpdateFirewallHook(ctx context.Context, key *meta.Key, obj *ga.Firewall, m *cloud.MockFirewalls) error
- func UpdateFirewallsUnauthorizedErrHook(ctx context.Context, key *meta.Key, obj *ga.Firewall, m *cloud.MockFirewalls) error
- func UpdateHealthCheckHook(ctx context.Context, key *meta.Key, obj *ga.HealthCheck, ...) error
- func UpdateRegionBackendServiceHook(ctx context.Context, key *meta.Key, obj *ga.BackendService, ...) error
- type AddressAttributes
- type InstanceGroupAttributes
- func (igAttrs *InstanceGroupAttributes) AddInstances(key *meta.Key, instanceRefs []*ga.InstanceReference) error
- func (igAttrs *InstanceGroupAttributes) List(key *meta.Key) []*ga.InstanceWithNamedPorts
- func (igAttrs *InstanceGroupAttributes) RemoveInstances(key *meta.Key, instanceRefs []*ga.InstanceReference) error
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 ¶ added in v1.11.0
func AddInstancesHook(ctx context.Context, key *meta.Key, req *ga.InstanceGroupsAddInstancesRequest, m *cloud.MockInstanceGroups) error
AddInstancesHook mocks adding instances from an InstanceGroup
func DeleteAddressesInternalErrHook ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
func ListInstancesHook(ctx context.Context, key *meta.Key, req *ga.InstanceGroupsListInstancesRequest, filter *filter.F, m *cloud.MockInstanceGroups) ([]*ga.InstanceWithNamedPorts, error)
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 ¶ added in v1.11.0
func RemoveInstancesHook(ctx context.Context, key *meta.Key, req *ga.InstanceGroupsRemoveInstancesRequest, m *cloud.MockInstanceGroups) error
RemoveInstancesHook mocks removing instances from an InstanceGroup
func UpdateFirewallHook ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
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 ¶ added in v1.11.0
func (igAttrs *InstanceGroupAttributes) AddInstances(key *meta.Key, instanceRefs []*ga.InstanceReference) error
AddInstances adds a list of Instances passed by InstanceReference
func (*InstanceGroupAttributes) List ¶ added in v1.11.0
func (igAttrs *InstanceGroupAttributes) List(key *meta.Key) []*ga.InstanceWithNamedPorts
List gets a list of InstanceWithNamedPorts
func (*InstanceGroupAttributes) RemoveInstances ¶ added in v1.11.0
func (igAttrs *InstanceGroupAttributes) RemoveInstances(key *meta.Key, instanceRefs []*ga.InstanceReference) error
RemoveInstances removes a list of Instances passed by InstanceReference