testing

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoResyncPeriod time.Duration = 0

	ContextLines = 4

	TestNamespace = "test-namespace"
	TestApp       = "shipper-test"
	TestRegion    = "eu-west"
	TestCluster   = "test-cluster"

	E2ETestNamespaceLabel = "shipper-e2e-test"
)

Variables

This section is empty.

Functions

func CheckAction

func CheckAction(expected, actual kubetesting.Action, t *testing.T)

CheckAction compares two individual actions and calls Errorf on t if it finds a difference.

func CheckActions

func CheckActions(expected, actual []kubetesting.Action, t *testing.T)

CheckActions takes a slice of expected actions and a slice of observed actions (typically obtained from fakeClient.Actions()) and compares them. Calls Errorf on t for every difference it finds.

func CheckEvents

func CheckEvents(expectedOrderedEvents []string, receivedEvents []string, t *testing.T)

func DeepEqualDiff added in v0.8.0

func DeepEqualDiff(expected, actual interface{}) (bool, string)

func FilterActions

func FilterActions(actions []kubetesting.Action) []kubetesting.Action

FilterActions, given a slice of observed actions, returns only those that change state. Useful for reducing the number of actions needed to check in tests.

func NewDiscoveryAction added in v0.5.0

func NewDiscoveryAction(_ string) kubetesting.ActionImpl

func PrettyPrintActions added in v0.5.0

func PrettyPrintActions(actions []kubetesting.Action, t *testing.T)

PrettyPrintActions pretty-prints a slice of actions, useful for creating a human-readable list for debugging.

func ShallowCheckAction

func ShallowCheckAction(expected, actual kubetesting.Action, t *testing.T)

ShallowCheckAction checks the verb, resource, and namespace without looking at the objects involved. This is a stand-in until we port the Installation controller to not use 'nil' as the object involved in the kubetesting.Actions it expects.

func ShallowCheckActions

func ShallowCheckActions(expected, actual []kubetesting.Action, t *testing.T)

ShallowCheckActions takes a slice of expected actions and a slice of observed actions (typically obtained from fakeClient.Actions()) and compares them shallowly. Calls Errorf on t for every difference it finds.

func YamlDiff added in v0.8.0

func YamlDiff(a interface{}, b interface{}) (string, error)

Types

type ControllerTestFixture added in v0.8.0

type ControllerTestFixture struct {
	ShipperClient          *shipperfake.Clientset
	ShipperInformerFactory shipperinformers.SharedInformerFactory

	Clusters           map[string]*FakeCluster
	ClusterClientStore *FakeClusterClientStore

	Recorder *record.FakeRecorder
}

func NewControllerTestFixture added in v0.8.0

func NewControllerTestFixture(objects ...runtime.Object) *ControllerTestFixture

func (*ControllerTestFixture) AddCluster added in v0.8.0

func (f *ControllerTestFixture) AddCluster() *FakeCluster

func (*ControllerTestFixture) AddNamedCluster added in v0.8.0

func (f *ControllerTestFixture) AddNamedCluster(name string) *FakeCluster

func (*ControllerTestFixture) DynamicClientBuilder added in v0.8.0

func (f *ControllerTestFixture) DynamicClientBuilder(
	kind *schema.GroupVersionKind,
	restConfig *rest.Config,
	cluster *shipper.Cluster,
) dynamic.Interface

func (*ControllerTestFixture) Run added in v0.8.0

func (f *ControllerTestFixture) Run(stopCh chan struct{})

type FakeCluster added in v0.7.0

type FakeCluster struct {
	Name string

	Client          *kubefake.Clientset
	DynamicClient   *fakedynamic.FakeDynamicClient
	InformerFactory informers.SharedInformerFactory
}

func NewNamedFakeCluster added in v0.7.0

func NewNamedFakeCluster(name string) *FakeCluster

func (*FakeCluster) AddMany added in v0.7.0

func (c *FakeCluster) AddMany(objects []runtime.Object)

func (*FakeCluster) AddOne added in v0.7.0

func (c *FakeCluster) AddOne(object runtime.Object)

func (*FakeCluster) InitializeDiscovery added in v0.8.0

func (c *FakeCluster) InitializeDiscovery(resources []*v1.APIResourceList)

func (*FakeCluster) InitializeDynamicClient added in v0.8.0

func (c *FakeCluster) InitializeDynamicClient(objects []runtime.Object)

type FakeClusterClientStore

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

FakeClusterClientStore is a fake implementation of a ClusterClientStore, allowing you to provide your own clientsets.

func NewFakeClusterClientStore

func NewFakeClusterClientStore(clusters map[string]*FakeCluster) *FakeClusterClientStore

func (*FakeClusterClientStore) AddCluster added in v0.8.0

func (s *FakeClusterClientStore) AddCluster(c *FakeCluster)

func (*FakeClusterClientStore) AddEventHandlerCallback

func (*FakeClusterClientStore) AddSubscriptionCallback

func (*FakeClusterClientStore) GetClient

func (s *FakeClusterClientStore) GetClient(clusterName string, ua string) (kubernetes.Interface, error)

func (*FakeClusterClientStore) GetConfig added in v0.7.0

func (s *FakeClusterClientStore) GetConfig(clusterName string) (*rest.Config, error)

func (*FakeClusterClientStore) GetInformerFactory

func (s *FakeClusterClientStore) GetInformerFactory(clusterName string) (informers.SharedInformerFactory, error)

func (*FakeClusterClientStore) Run

func (s *FakeClusterClientStore) Run(stopCh <-chan struct{})

Jump to

Keyboard shortcuts

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