testingutil

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const TestTag = "test"

Variables

This section is empty.

Functions

func AssertEqualsEngineStatus

func AssertEqualsEngineStatus(t *testing.T, expectedEngineStatus, actualEngineStatus model.EngineStatus)

func AssertEqualsField

func AssertEqualsField(t *testing.T, a, b model.Field)

func AssertEqualsResource

func AssertEqualsResource(t *testing.T, a, b model.Resource)

func AssertEqualsResourcePter

func AssertEqualsResourcePter(t *testing.T, a, b *model.Resource)

func AssertEqualsResources

func AssertEqualsResources(t *testing.T, a, b model.Resources)

func AssertEqualsTag

func AssertEqualsTag(t *testing.T, a, b *model.Tag)

func AssertEqualsTags

func AssertEqualsTags(t *testing.T, a, b model.Tags)

func AssertResourceCount

func AssertResourceCount(t testing.TB, resources []model.Resource, tagValue string, count int)

AssertResourceCount asserts that there is a specific number of given resources with the "test" tag. If tagValue is not an empty string, it also filters on resources that have the "test" tag with that value.

func AssertResourceFilteredCount

func AssertResourceFilteredCount(t testing.TB, resources []model.Resource, count int, filter ResourceFilter) []model.Resource

func FetchAll

func FetchAll[T any](ctx context.Context, t testing.TB, f func(context.Context, chan<- T) error) ([]T, error)

FetchAll pulls all resources from `f` over the passed channel, returning the resources as a slice

func FilterFunc

func FilterFunc[T any](in []T, predicate func(T) bool) []T

FilterFunc filters a slice based on the predicate function

func FuncSignature

func FuncSignature(value any) string

FuncSignature returns the signature of a function as a string, useful for error messages.

func JSONBytesEqual

func JSONBytesEqual(a, b []byte) (bool, error)

JSONBytesEqual compares the JSON in two byte slices.

func MustFetchAll

func MustFetchAll[T any](ctx context.Context, t testing.TB, f func(context.Context, chan<- T) error) []T

MustFetchAll is like FetchAll, but fatals the running test if there is an error during fetching

func ResourceFilterTagKey

func ResourceFilterTagKey(in []model.Resource, key string) []model.Resource

ResourceFilterTagKey filters a slice of model.Resources based on a given tag key being present on that resource.

func ResourceFilterTagKeyValue

func ResourceFilterTagKeyValue(in []model.Resource, key, value string) []model.Resource

ResourceFilterTagKey filters a slice of model.Resources based on a given tag key/value pair being present on that resource.

func SliceConvertFunc

func SliceConvertFunc[In any, Out any, T ~[]In](in T, f func(In) Out) []Out

func TypeStr

func TypeStr(v any) string

TypeStr is a convenience function to get the fully qualified type identifier for a value

func Unique

func Unique[T comparable](in []T) []T

Unique returns a new slice with duplicate elements removed and the order preserved.

Types

type ResourceFilter

type ResourceFilter struct {
	Region  string
	Type    string
	Tags    model.Tags
	RawData map[string]any
}

func (ResourceFilter) Filter

func (f ResourceFilter) Filter(in []model.Resource) []model.Resource

func (ResourceFilter) Matches

func (f ResourceFilter) Matches(resource model.Resource) bool

func (ResourceFilter) String

func (f ResourceFilter) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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