testutil

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// core
	IsCoreV1NamespacePtr     = mock.IsType(&corev1.Namespace{})
	IsCoreV1NamespaceListPtr = mock.IsType(&corev1.NamespaceList{})
	IsConfigMapPtr           = mock.IsType(&corev1.ConfigMap{})

	// networking
	IsNetworkingV1NetworkPolicyPtr = mock.IsType(&networkingv1.NetworkPolicy{})

	// olm
	IsOperatorsV1OperatorGroupPtr       = mock.IsType(&operatorsv1.OperatorGroup{})
	IsOperatorsV1Alpha1CatalogSourcePtr = mock.IsType(&operatorsv1alpha1.CatalogSource{})
	IsOperatorsV1Alpha1SubscriptionPtr  = mock.IsType(&operatorsv1alpha1.Subscription{})
	IsOperatorsV1OperatorPtr            = mock.IsType(&operatorsv1.Operator{})

	// prom
	IsMonitoringV1ServiceMonitorPtr = mock.IsType(&monitoringv1.ServiceMonitor{})

	// addon.managed.openshift.io/v1alpha1
	IsAddonsv1alpha1AddonPtr             = mock.IsType(&addonsv1alpha1.Addon{})
	IsAddonsv1alpha1AddonListPtr         = mock.IsType(&addonsv1alpha1.AddonList{})
	IsAddonsv1alpha1AddonOperatorPtr     = mock.IsType(&addonsv1alpha1.AddonOperator{})
	IsAddonsv1alpha1AddonOperatorListPtr = mock.IsType(&addonsv1alpha1.AddonOperatorList{})

	// misc
	IsContext   = mock.IsType(context.TODO())
	IsObjectKey = mock.IsType(client.ObjectKey{})
)

custom testify/mock matchers

Functions

func AssertConditionsMatch added in v1.5.4

func AssertConditionsMatch(t *testing.T, condsA []metav1.Condition, condsB []metav1.Condition)

func IsApiMockEnabled added in v0.7.0

func IsApiMockEnabled() bool

func IsWebhookServerEnabled added in v0.3.0

func IsWebhookServerEnabled() bool

func NewAddonWithInstallSpec added in v0.3.0

func NewAddonWithInstallSpec(installSpec addonsv1alpha1.AddonInstallSpec,
	addonName string) *addonsv1alpha1.Addon

NewAddonWithInstallSpec returns an Addon object with the specified InstallSpec

func NewLogger

func NewLogger(t *testing.T) logr.Logger

NewLogger returns a new Logger flushing to testing.T.

func NewStatusError added in v0.3.0

func NewStatusError(msg string) *k8sApiErrors.StatusError

NewStatusError returns an error of type `StatusError `

func NewTestAddonWithAdditionalCatalogSources added in v1.4.0

func NewTestAddonWithAdditionalCatalogSources() *addonsv1alpha1.Addon

func NewTestAddonWithCatalogSourceImage added in v0.5.0

func NewTestAddonWithCatalogSourceImage() *addonsv1alpha1.Addon

func NewTestAddonWithMonitoringFederation added in v1.4.1

func NewTestAddonWithMonitoringFederation() *addonsv1alpha1.Addon

func NewTestAddonWithMultipleNamespaces added in v0.5.0

func NewTestAddonWithMultipleNamespaces() *addonsv1alpha1.Addon

func NewTestAddonWithSingleNamespace added in v0.5.0

func NewTestAddonWithSingleNamespace() *addonsv1alpha1.Addon

func NewTestAddonWithoutNamespace added in v0.5.0

func NewTestAddonWithoutNamespace() *addonsv1alpha1.Addon

func NewTestCatalogSource added in v0.5.0

func NewTestCatalogSource() *operatorsv1alpha1.CatalogSource

func NewTestCatalogSourceWithoutOwner added in v0.5.0

func NewTestCatalogSourceWithoutOwner() *operatorsv1alpha1.CatalogSource

func NewTestErrNotFound added in v0.5.0

func NewTestErrNotFound() *k8sApiErrors.StatusError

func NewTestExistingNamespace added in v0.7.0

func NewTestExistingNamespace() *corev1.Namespace

func NewTestNamespace added in v0.5.0

func NewTestNamespace() *corev1.Namespace

func NewTestNamespaceWithoutOwner added in v0.7.0

func NewTestNamespaceWithoutOwner() *corev1.Namespace

func NewTestOperatorGroup added in v0.7.0

func NewTestOperatorGroup() *operatorsv1.OperatorGroup

func NewTestOperatorGroupWithoutOwner added in v0.7.0

func NewTestOperatorGroupWithoutOwner() *operatorsv1.OperatorGroup

func NewTestSchemeWithAddonsv1alpha1 added in v0.5.0

func NewTestSchemeWithAddonsv1alpha1() *runtime.Scheme

func NewTestSubscription added in v0.7.0

func NewTestSubscription() *operatorsv1alpha1.Subscription

func NewTestSubscriptionWithoutOwner added in v0.7.0

func NewTestSubscriptionWithoutOwner() *operatorsv1alpha1.Subscription

Types

type Client

type Client struct {
	mock.Mock

	StatusMock *StatusClient
}

Client is a mock for the controller-runtime dynamic client interface.

func NewClient

func NewClient() *Client

func (*Client) Create

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

func (*Client) Delete

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

func (*Client) DeleteAllOf

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

func (*Client) Get

func (c *Client) Get(ctx context.Context, key types.NamespacedName, obj client.Object) error

func (*Client) List

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

func (*Client) Patch

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

func (*Client) RESTMapper

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

func (*Client) Scheme

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

func (*Client) Status

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

func (*Client) Update

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

type Logger

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

Logger implements logr.Logger and logs to testing.T to preserve the order of log lines in tests.

func (*Logger) Enabled

func (l *Logger) Enabled(level int) bool

Enabled implements logr.LogSink.Enabled

func (*Logger) Error

func (l *Logger) Error(err error, msg string, kvs ...interface{})

Error implements logr.LogSink.Error

func (*Logger) Info

func (l *Logger) Info(level int, msg string, kvs ...interface{})

Info implements logr.LogSink.Info

func (*Logger) Init added in v0.7.0

func (l *Logger) Init(info logr.RuntimeInfo)

Init implements logr.LogSink.Init

func (*Logger) WithName

func (l *Logger) WithName(name string) logr.LogSink

WithName implements logr.LogSink.WithName

func (*Logger) WithValues

func (l *Logger) WithValues(kvs ...interface{}) logr.LogSink

WithValues implements logr.LogSink.WithValues

type StatusClient

type StatusClient struct {
	mock.Mock
}

func (*StatusClient) Patch

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

func (*StatusClient) Update

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

type Summary added in v0.7.0

type Summary struct {
	mock.Mock
}

Summary is a mock object for `prometheus.Summary`

func NewSummaryMock added in v0.7.0

func NewSummaryMock() *Summary

func (*Summary) Collect added in v0.7.0

func (s *Summary) Collect(m chan<- prometheus.Metric)

implement `prometheus.Collector` interface

func (*Summary) Desc added in v0.7.0

func (s *Summary) Desc() *prometheus.Desc

implement `prometheus.Metric` interface

func (*Summary) Describe added in v0.7.0

func (s *Summary) Describe(c chan<- *prometheus.Desc)

implement `prometheus.Collector` interface

func (*Summary) Observe added in v0.7.0

func (s *Summary) Observe(d float64)

func (*Summary) Write added in v0.7.0

func (s *Summary) Write(m *dto.Metric) error

implement `prometheus.Metric` interface

Jump to

Keyboard shortcuts

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