testutil

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: Apache-2.0 Imports: 36 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DateRegex = "20\\d\\d"
View Source
var DefaultRetry = wait.Backoff{
	Duration: 10 * time.Microsecond,
	Factor:   1.0,
	Jitter:   0.1,
	Steps:    500,
}
View Source
var RuntimeObjCmpOpts = []cmp.Option{
	cmpopts.IgnoreTypes(metav1.TypeMeta{}),
	cmpopts.IgnoreFields(metav1.ObjectMeta{}, "ResourceVersion", "SelfLink", "Generation", "CreationTimestamp"),
}
View Source
var SkippedPaths = map[string]bool{
	"Godeps":      true,
	"third_party": true,
	"_gopath":     true,
	"_artifacts":  true,
	"_output":     true,
	".git":        true,
	"vendor":      true,
	"external":    true,
	"3rdparty":    true,
	"deploy":      true,
}

Functions

func AssertDiff

func AssertDiff(t *testing.T, expected interface{}, actual interface{})

AssertDiff compares an expected interface with an actual interface and fails if the two interfaces do not match. This func removes all metadata calico annotations.

func InitScheme

func InitScheme(t *testing.T) *runtime.Scheme

func ReadOrUpdateGoldenFile

func ReadOrUpdateGoldenFile(t *testing.T, content string, update bool) string

func Yamlizers

func Yamlizers(t *testing.T, scheme *runtime.Scheme) (func([]byte) runtime.Object, func(runtime.Object, io.Writer) error)

Types

type Action

type Action interface {
	Verb() string
	GVR() schema.GroupVersionResource
	Key() client.ObjectKey
}

func NewCreateAction

func NewCreateAction(key client.ObjectKey, gvr schema.GroupVersionResource) Action

func NewGetAction

func NewGetAction(key client.ObjectKey, gvr schema.GroupVersionResource) Action

type ClusterBuilder

type ClusterBuilder struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder(name string) ClusterBuilder

func (ClusterBuilder) Cluster

func (b ClusterBuilder) Cluster() *resource.Cluster

func (ClusterBuilder) Cr

func (b ClusterBuilder) Cr() *api.CrdbCluster

func (ClusterBuilder) Namespaced

func (b ClusterBuilder) Namespaced(namespace string) ClusterBuilder

func (ClusterBuilder) WithHTTPPort

func (b ClusterBuilder) WithHTTPPort(port int32) ClusterBuilder

func (ClusterBuilder) WithImage

func (b ClusterBuilder) WithImage(image string) ClusterBuilder

func (ClusterBuilder) WithMaxUnavailable

func (b ClusterBuilder) WithMaxUnavailable(max *int32) ClusterBuilder

func (ClusterBuilder) WithNodeCount

func (b ClusterBuilder) WithNodeCount(c int32) ClusterBuilder

func (ClusterBuilder) WithNodeTLS

func (b ClusterBuilder) WithNodeTLS(secret string) ClusterBuilder

func (ClusterBuilder) WithPVDataStore

func (b ClusterBuilder) WithPVDataStore(size, storageClass string) ClusterBuilder

func (ClusterBuilder) WithTLS

func (b ClusterBuilder) WithTLS() ClusterBuilder

func (ClusterBuilder) WithUID

func (b ClusterBuilder) WithUID(uid string) ClusterBuilder

type CreateAction

type CreateAction struct {
	// contains filtered or unexported fields
}

func (CreateAction) GVR

func (CreateAction) Key

func (a CreateAction) Key() client.ObjectKey

func (CreateAction) Verb

func (a CreateAction) Verb() string

type FakeClient

type FakeClient struct {

	// ReactionChain is the list of reactors that will be attempted for every
	// request in the order they are tried.
	ReactionChain []Reactor
	// contains filtered or unexported fields
}

FakeClient is inspired and taken from https://github.com/kubernetes/client-go/

func NewFakeClient

func NewFakeClient(scheme *runtime.Scheme, objs ...runtime.Object) *FakeClient

func (*FakeClient) AddReactor

func (c *FakeClient) AddReactor(verb string, resource string, reaction ReactionFunc)

func (*FakeClient) Create

func (c *FakeClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error

func (*FakeClient) Delete

func (c *FakeClient) Delete(_ context.Context, obj client.Object, opts ...client.DeleteOption) error

func (*FakeClient) DeleteAllOf

func (c *FakeClient) DeleteAllOf(_ context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error

func (*FakeClient) Get

func (c *FakeClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error

func (*FakeClient) List

func (c *FakeClient) List(_ context.Context, list client.ObjectList, opts ...client.ListOption) error

func (*FakeClient) Patch

func (c *FakeClient) Patch(_ context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

func (*FakeClient) RESTMapper

func (c *FakeClient) RESTMapper() meta.RESTMapper

func (*FakeClient) Scheme

func (c *FakeClient) Scheme() *runtime.Scheme

func (*FakeClient) Status

func (c *FakeClient) Status() client.StatusWriter

func (*FakeClient) Update

func (c *FakeClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

type GetAction

type GetAction struct {
	// contains filtered or unexported fields
}

func (GetAction) GVR

func (GetAction) Key

func (a GetAction) Key() client.ObjectKey

func (GetAction) Verb

func (a GetAction) Verb() string

type ReactionFunc

type ReactionFunc func(action Action) (handled bool, err error)

ReactionFunc is a function returning `handled` set to true if no further processing is required and an error if one needs to be raised

type Reactor

type Reactor interface {
	// Handles indicates whether or not this Reactor deals with a given
	// action.
	Handles(action Action) bool
	// React handles the action and returns results.  It may choose to
	// delegate by indicated handled=false.
	React(action Action) (handled bool, err error)
}

Reactor is an interface to allow the composition of reaction functions.

type ValidateHeaders

type ValidateHeaders struct {
	// contains filtered or unexported fields
}

ValidateHeaders represents a project that that needs to be scanned.

func NewValidateHeaders

func NewValidateHeaders(fileNames *[]string, rootDir string, boilerplateDir string, forceExtension string) ValidateHeaders

NewValidateHeaders creates a new struct used to validate a project.

func (ValidateHeaders) Validate

func (v ValidateHeaders) Validate() (nonconformingFilesPtr *[]string, err error)

Validate iterates over a set of files and returns a slice of files that do not have the proper headers. A slice of files are returned that containes the filenames of files that do not have a header that matches the boilerplate.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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