elbv2iface

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package elbv2iface provides an interface to enable mocking the Elastic Load Balancing service client for testing your code.

It is important to note that this interface will have breaking changes when the service model is updated and adds new API operations, paginators, and waiters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ELBV2API

type ELBV2API interface {
	AddListenerCertificatesRequest(*elbv2.AddListenerCertificatesInput) elbv2.AddListenerCertificatesRequest

	AddTagsRequest(*elbv2.AddTagsInput) elbv2.AddTagsRequest

	CreateListenerRequest(*elbv2.CreateListenerInput) elbv2.CreateListenerRequest

	CreateLoadBalancerRequest(*elbv2.CreateLoadBalancerInput) elbv2.CreateLoadBalancerRequest

	CreateRuleRequest(*elbv2.CreateRuleInput) elbv2.CreateRuleRequest

	CreateTargetGroupRequest(*elbv2.CreateTargetGroupInput) elbv2.CreateTargetGroupRequest

	DeleteListenerRequest(*elbv2.DeleteListenerInput) elbv2.DeleteListenerRequest

	DeleteLoadBalancerRequest(*elbv2.DeleteLoadBalancerInput) elbv2.DeleteLoadBalancerRequest

	DeleteRuleRequest(*elbv2.DeleteRuleInput) elbv2.DeleteRuleRequest

	DeleteTargetGroupRequest(*elbv2.DeleteTargetGroupInput) elbv2.DeleteTargetGroupRequest

	DeregisterTargetsRequest(*elbv2.DeregisterTargetsInput) elbv2.DeregisterTargetsRequest

	DescribeAccountLimitsRequest(*elbv2.DescribeAccountLimitsInput) elbv2.DescribeAccountLimitsRequest

	DescribeListenerCertificatesRequest(*elbv2.DescribeListenerCertificatesInput) elbv2.DescribeListenerCertificatesRequest

	DescribeListenersRequest(*elbv2.DescribeListenersInput) elbv2.DescribeListenersRequest

	DescribeListenersPages(*elbv2.DescribeListenersInput, func(*elbv2.DescribeListenersOutput, bool) bool) error
	DescribeListenersPagesWithContext(aws.Context, *elbv2.DescribeListenersInput, func(*elbv2.DescribeListenersOutput, bool) bool, ...aws.Option) error

	DescribeLoadBalancerAttributesRequest(*elbv2.DescribeLoadBalancerAttributesInput) elbv2.DescribeLoadBalancerAttributesRequest

	DescribeLoadBalancersRequest(*elbv2.DescribeLoadBalancersInput) elbv2.DescribeLoadBalancersRequest

	DescribeLoadBalancersPages(*elbv2.DescribeLoadBalancersInput, func(*elbv2.DescribeLoadBalancersOutput, bool) bool) error
	DescribeLoadBalancersPagesWithContext(aws.Context, *elbv2.DescribeLoadBalancersInput, func(*elbv2.DescribeLoadBalancersOutput, bool) bool, ...aws.Option) error

	DescribeRulesRequest(*elbv2.DescribeRulesInput) elbv2.DescribeRulesRequest

	DescribeSSLPoliciesRequest(*elbv2.DescribeSSLPoliciesInput) elbv2.DescribeSSLPoliciesRequest

	DescribeTagsRequest(*elbv2.DescribeTagsInput) elbv2.DescribeTagsRequest

	DescribeTargetGroupAttributesRequest(*elbv2.DescribeTargetGroupAttributesInput) elbv2.DescribeTargetGroupAttributesRequest

	DescribeTargetGroupsRequest(*elbv2.DescribeTargetGroupsInput) elbv2.DescribeTargetGroupsRequest

	DescribeTargetGroupsPages(*elbv2.DescribeTargetGroupsInput, func(*elbv2.DescribeTargetGroupsOutput, bool) bool) error
	DescribeTargetGroupsPagesWithContext(aws.Context, *elbv2.DescribeTargetGroupsInput, func(*elbv2.DescribeTargetGroupsOutput, bool) bool, ...aws.Option) error

	DescribeTargetHealthRequest(*elbv2.DescribeTargetHealthInput) elbv2.DescribeTargetHealthRequest

	ModifyListenerRequest(*elbv2.ModifyListenerInput) elbv2.ModifyListenerRequest

	ModifyLoadBalancerAttributesRequest(*elbv2.ModifyLoadBalancerAttributesInput) elbv2.ModifyLoadBalancerAttributesRequest

	ModifyRuleRequest(*elbv2.ModifyRuleInput) elbv2.ModifyRuleRequest

	ModifyTargetGroupRequest(*elbv2.ModifyTargetGroupInput) elbv2.ModifyTargetGroupRequest

	ModifyTargetGroupAttributesRequest(*elbv2.ModifyTargetGroupAttributesInput) elbv2.ModifyTargetGroupAttributesRequest

	RegisterTargetsRequest(*elbv2.RegisterTargetsInput) elbv2.RegisterTargetsRequest

	RemoveListenerCertificatesRequest(*elbv2.RemoveListenerCertificatesInput) elbv2.RemoveListenerCertificatesRequest

	RemoveTagsRequest(*elbv2.RemoveTagsInput) elbv2.RemoveTagsRequest

	SetIpAddressTypeRequest(*elbv2.SetIpAddressTypeInput) elbv2.SetIpAddressTypeRequest

	SetRulePrioritiesRequest(*elbv2.SetRulePrioritiesInput) elbv2.SetRulePrioritiesRequest

	SetSecurityGroupsRequest(*elbv2.SetSecurityGroupsInput) elbv2.SetSecurityGroupsRequest

	SetSubnetsRequest(*elbv2.SetSubnetsInput) elbv2.SetSubnetsRequest

	WaitUntilLoadBalancerAvailable(*elbv2.DescribeLoadBalancersInput) error
	WaitUntilLoadBalancerAvailableWithContext(aws.Context, *elbv2.DescribeLoadBalancersInput, ...aws.WaiterOption) error

	WaitUntilLoadBalancerExists(*elbv2.DescribeLoadBalancersInput) error
	WaitUntilLoadBalancerExistsWithContext(aws.Context, *elbv2.DescribeLoadBalancersInput, ...aws.WaiterOption) error

	WaitUntilLoadBalancersDeleted(*elbv2.DescribeLoadBalancersInput) error
	WaitUntilLoadBalancersDeletedWithContext(aws.Context, *elbv2.DescribeLoadBalancersInput, ...aws.WaiterOption) error

	WaitUntilTargetDeregistered(*elbv2.DescribeTargetHealthInput) error
	WaitUntilTargetDeregisteredWithContext(aws.Context, *elbv2.DescribeTargetHealthInput, ...aws.WaiterOption) error

	WaitUntilTargetInService(*elbv2.DescribeTargetHealthInput) error
	WaitUntilTargetInServiceWithContext(aws.Context, *elbv2.DescribeTargetHealthInput, ...aws.WaiterOption) error
}

ELBV2API provides an interface to enable mocking the elbv2.ELBV2 service client's API operation, paginators, and waiters. This make unit testing your code that calls out to the SDK's service client's calls easier.

The best way to use this interface is so the SDK's service client's calls can be stubbed out for unit testing your code with the SDK without needing to inject custom request handlers into the SDK's request pipeline.

// myFunc uses an SDK service client to make a request to
// Elastic Load Balancing.
func myFunc(svc elbv2iface.ELBV2API) bool {
    // Make svc.AddListenerCertificates request
}

func main() {
    cfg, err := external.LoadDefaultAWSConfig()
    if err != nil {
        panic("failed to load config, " + err.Error())
    }

    svc := elbv2.New(cfg)

    myFunc(svc)
}

In your _test.go file:

// Define a mock struct to be used in your unit tests of myFunc.
type mockELBV2Client struct {
    elbv2iface.ELBV2API
}
func (m *mockELBV2Client) AddListenerCertificates(input *elbv2.AddListenerCertificatesInput) (*elbv2.AddListenerCertificatesOutput, error) {
    // mock response/functionality
}

func TestMyFunc(t *testing.T) {
    // Setup Test
    mockSvc := &mockELBV2Client{}

    myfunc(mockSvc)

    // Verify myFunc's functionality
}

It is important to note that this interface will have breaking changes when the service model is updated and adds new API operations, paginators, and waiters. Its suggested to use the pattern above for testing, or using tooling to generate mocks to satisfy the interfaces.

Jump to

Keyboard shortcuts

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