fake

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fake provides a fake version of the GCE struct to return canned responses in unit tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetAddressByIPArguments

type GetAddressByIPArguments struct{ Project, Region, Address string }

GetAddressByIPArguments is a struct to match arguments passed in to the GetAddressbyIP function for validation.

type GetDiskArguments

type GetDiskArguments struct{ Project, Zone, DiskName string }

GetDiskArguments is a struct to match arguments passed in to the GetDisk function for validation.

type GetForwardingRuleArguments

type GetForwardingRuleArguments struct{ Project, Location, Name string }

GetForwardingRuleArguments is a struct to match arguments passed in to the GetForwardingRule function for validation.

type TestGCE

type TestGCE struct {
	T                    *testing.T
	GetInstanceResp      []*compute.Instance
	GetInstanceErr       []error
	GetInstanceCallCount int

	GetInstanceByIPResp      []*compute.Instance
	GetInstanceByIPErr       []error
	GetInstanceByIPCallCount int

	GetDiskResp      []*compute.Disk
	GetDiskArgs      []*GetDiskArguments
	GetDiskErr       []error
	GetDiskCallCount int

	ListZoneOperationsResp      []*compute.OperationList
	ListZoneOperationsErr       []error
	ListZoneOperationsCallCount int

	GetAddressResp      []*compute.Address
	GetAddressErr       []error
	GetAddressCallCount int

	GetAddressByIPResp      []*compute.Address
	GetAddressByIPArgs      []*GetAddressByIPArguments
	GetAddressByIPErr       []error
	GetAddressByIPCallCount int

	GetRegionalBackendServiceResp      []*compute.BackendService
	GetRegionalBackendServiceErr       []error
	GetRegionalBackendServiceCallCount int

	GetForwardingRuleResp       []*compute.ForwardingRule
	GetForwardingRuleErr        []error
	GetForwardingRuleArgs       []*GetForwardingRuleArguments
	GetForwardingRulleCallCount int

	GetInstanceGroupResp      []*compute.InstanceGroup
	GetInstanceGroupErr       []error
	GetInstanceGroupCallCount int

	ListInstanceGroupInstancesResp      []*compute.InstanceGroupsListInstances
	ListInstanceGroupInstancesErr       []error
	ListInstanceGroupInstancesCallCount int

	GetFilestoreByIPResp      []*file.ListInstancesResponse
	GetFilestoreByIPErr       []error
	GetFilestoreByIPCallCount int

	GetURIForIPResp      []string
	GetURIForIPErr       []error
	GetURIForIPCallCount int

	GetSecretResp      []string
	GetSecretErr       []error
	GetSecretCallCount int
}

TestGCE implements GCE interfaces. A new TestGCE instance should be used per iteration of the test.

func (*TestGCE) GetAddress

func (g *TestGCE) GetAddress(project, location, name string) (*compute.Address, error)

GetAddress fakes a call to the compute API to retrieve a list of addresses.

func (*TestGCE) GetAddressByIP

func (g *TestGCE) GetAddressByIP(project, region, address string) (*compute.Address, error)

GetAddressByIP fakes a call to the compute API to retrieve a list of addresses.

func (*TestGCE) GetDisk

func (g *TestGCE) GetDisk(project, zone, disk string) (*compute.Disk, error)

GetDisk fakes a call to the compute API to retrieve a GCE Persistent Disk.

func (*TestGCE) GetFilestoreByIP

func (g *TestGCE) GetFilestoreByIP(project, location, ip string) (*file.ListInstancesResponse, error)

GetFilestoreByIP fakes a call to the compute API to retrieve a filestore instance by its IP address.

func (*TestGCE) GetForwardingRule

func (g *TestGCE) GetForwardingRule(project, location, name string) (*compute.ForwardingRule, error)

GetForwardingRule fakes a call to the compute API to retrieve a forwarding rule.

func (*TestGCE) GetInstance

func (g *TestGCE) GetInstance(project, zone, instance string) (*compute.Instance, error)

GetInstance fakes a call to the compute API to retrieve a GCE Instance.

func (*TestGCE) GetInstanceByIP

func (g *TestGCE) GetInstanceByIP(project, ip string) (*compute.Instance, error)

GetInstanceByIP fakes a call to the compute API to retrieve a compute instance by its IP address.

func (*TestGCE) GetInstanceGroup

func (g *TestGCE) GetInstanceGroup(project, zone, name string) (*compute.InstanceGroup, error)

GetInstanceGroup fakes a call to the compute API to retrieve an Instance Group.

func (*TestGCE) GetRegionalBackendService

func (g *TestGCE) GetRegionalBackendService(project, region, name string) (*compute.BackendService, error)

GetRegionalBackendService fakes a call to the compute API to retrieve a regional backend service.

func (*TestGCE) GetSecret

func (g *TestGCE) GetSecret(ctx context.Context, projectID, secretName string) (string, error)

GetSecret fakes calls to secretmanager APIs to access a secret version.

func (*TestGCE) GetURIForIP

func (g *TestGCE) GetURIForIP(project, ip string) (string, error)

GetURIForIP fakes calls to compute APIs to locate an object URI related to the IP address provided.

func (*TestGCE) ListInstanceGroupInstances

func (g *TestGCE) ListInstanceGroupInstances(project, zone, name string) (*compute.InstanceGroupsListInstances, error)

ListInstanceGroupInstances fakes a call to the compute API to retrieve a list of instances in an instance group.

func (*TestGCE) ListZoneOperations

func (g *TestGCE) ListZoneOperations(project, zone, filter string, maxResults int64) (*compute.OperationList, error)

ListZoneOperations fakes a call to the compute API to retrieve a list of Operations resources.

Jump to

Keyboard shortcuts

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