testutils

package
v0.2.42 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testutils implements test utilities.

Package testutils implements test utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	// EchoFunc is a helper to echo out the say command passsed in a Do.
	EchoFunc = func(ctx context.Context, cmd map[string]interface{}) (map[string]interface{}, error) {
		return cmd, nil
	}

	// TestCommand is a dummy command to send for a DoCommand.
	TestCommand = map[string]interface{}{"command": "test", "data": 500}
)

Functions

func AddRemotes

func AddRemotes(values []resource.Name, remotes ...string) []resource.Name

AddRemotes takes a slice of resource.Name objects and for each remote, adds the remote to every object, then returns the entire list.

func AddSuffixes

func AddSuffixes(values []resource.Name, suffixes ...string) []resource.Name

AddSuffixes takes a slice of resource.Name objects and for each suffix, adds the suffix to every object, then returns the entire list.

func ConcatResourceNames

func ConcatResourceNames(values ...[]resource.Name) []resource.Name

ConcatResourceNames takes a slice of slices of resource.Name objects and returns a concatenated slice of resource.Name for the purposes of comparison in automated tests.

func ExtractNames

func ExtractNames(values ...resource.Name) []string

ExtractNames takes a slice of resource.Name objects and returns a slice of name strings for the purposes of comparison in automated tests.

func NewResourceNameSet

func NewResourceNameSet(resourceNames ...resource.Name) map[resource.Name]struct{}

NewResourceNameSet returns a flattened set of name strings from a collection of resource.Name objects for the purposes of comparison in automated tests.

func NewUnimplementedResource added in v0.2.36

func NewUnimplementedResource(name resource.Name) resource.Resource

NewUnimplementedResource returns a resource that has all methods unimplemented.

func SubtractNames added in v0.2.36

func SubtractNames(from []resource.Name, values ...resource.Name) []resource.Name

SubtractNames removes values from the first slice of resource names.

func SubtractNamesFromLevels added in v0.2.36

func SubtractNamesFromLevels(from [][]resource.Name, values ...resource.Name) [][]resource.Name

SubtractNamesFromLevels removes values from each slice of resource names.

func VerifyTopologicallySortedLevels added in v0.2.36

func VerifyTopologicallySortedLevels(t *testing.T, g *resource.Graph, levels [][]resource.Name, exclusions ...resource.Name)

VerifyTopologicallySortedLevels verifies each topological layer of a sort against the given levels from most dependencies to least dependencies.

Types

type FakeConvertedAttributes

type FakeConvertedAttributes struct {
	Thing string
}

FakeConvertedAttributes is a helper for testing if validation works.

func (*FakeConvertedAttributes) Validate

func (convAttr *FakeConvertedAttributes) Validate(path string) ([]string, error)

Validate validates that the single fake attribute Thing exists properly in the struct, meant to implement the validator interface in component.go.

type TrackingDialer

type TrackingDialer struct {
	rpc.Dialer
	NewConnections int
}

TrackingDialer tracks dial attempts.

func (*TrackingDialer) DialDirect

func (td *TrackingDialer) DialDirect(
	ctx context.Context,
	target string,
	keyExtra string,
	onClose func() error,
	opts ...grpc.DialOption,
) (rpc.ClientConn, bool, error)

DialDirect tracks calls of DialDirect.

func (*TrackingDialer) DialFunc

func (td *TrackingDialer) DialFunc(
	proto string,
	target string,
	keyExtra string,
	f func() (rpc.ClientConn, func() error, error),
) (rpc.ClientConn, bool, error)

DialFunc tracks calls of DialFunc.

Directories

Path Synopsis
Package inject provides dependency injected structures for mocking interfaces.
Package inject provides dependency injected structures for mocking interfaces.
Package robottestutils provides helper functions in testing
Package robottestutils provides helper functions in testing

Jump to

Keyboard shortcuts

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