mocks

package
v3.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminAPIClientFactory

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

AdminAPIClientFactory is a mock implementation of adminapi.ClientFactory.

func NewAdminAPIClientFactory

func NewAdminAPIClientFactory(errorsToReturn map[string]error) *AdminAPIClientFactory

func (*AdminAPIClientFactory) CreateAdminAPIClient

type AdminAPIDiscoverer

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

AdminAPIDiscoverer is a mock implementation of adminapi.Discoverer.

func NewAdminAPIDiscoverer

func NewAdminAPIDiscoverer(apisToReturn sets.Set[adminapi.DiscoveredAdminAPI], errToReturn error) *AdminAPIDiscoverer

func (*AdminAPIDiscoverer) AdminAPIsFromEndpointSlice

func (m *AdminAPIDiscoverer) AdminAPIsFromEndpointSlice(discoveryv1.EndpointSlice) (
	sets.Set[adminapi.DiscoveredAdminAPI],
	error,
)

func (*AdminAPIDiscoverer) AdminAPIsFromEndpointSliceCalledTimes

func (m *AdminAPIDiscoverer) AdminAPIsFromEndpointSliceCalledTimes() int

func (*AdminAPIDiscoverer) GetAdminAPIsForServiceCalledTimes

func (m *AdminAPIDiscoverer) GetAdminAPIsForServiceCalledTimes() int

type AdminAPIHandler

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

AdminAPIHandler is a mock implementation of the Admin API. It only implements the endpoints that are required for the tests.

func NewAdminAPIHandler

func NewAdminAPIHandler(t *testing.T, opts ...AdminAPIHandlerOpt) *AdminAPIHandler

func (*AdminAPIHandler) ServeHTTP

func (m *AdminAPIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*AdminAPIHandler) WasWorkspaceCreated

func (m *AdminAPIHandler) WasWorkspaceCreated() bool

type AdminAPIHandlerOpt

type AdminAPIHandlerOpt func(h *AdminAPIHandler)

func WithConfigPostError

func WithConfigPostError(errorbody []byte) AdminAPIHandlerOpt

func WithConfigPostErrorOnlyOnFirstRequest added in v3.2.0

func WithConfigPostErrorOnlyOnFirstRequest() AdminAPIHandlerOpt

func WithConfigurationHash

func WithConfigurationHash(hash string) AdminAPIHandlerOpt

func WithReady

func WithReady(ready bool) AdminAPIHandlerOpt

func WithRoot added in v3.2.0

func WithRoot(response []byte) AdminAPIHandlerOpt

func WithVersion

func WithVersion(version string) AdminAPIHandlerOpt

WithVersion sets the version string returned by mocked Kong instance. If version is empty, the default version is used.

func WithWorkspaceExists

func WithWorkspaceExists(exists bool) AdminAPIHandlerOpt

type ConfigStatusNotifier added in v3.4.3

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

ConfigStatusNotifier is a mock implementation of clients.ConfigStatusNotifier.

func (*ConfigStatusNotifier) FirstKonnectConfigStatus added in v3.4.3

func (c *ConfigStatusNotifier) FirstKonnectConfigStatus() (clients.KonnectConfigUploadStatus, bool)

func (*ConfigStatusNotifier) LastGatewayConfigStatus added in v3.4.3

func (c *ConfigStatusNotifier) LastGatewayConfigStatus() clients.GatewayConfigApplyStatus

func (*ConfigStatusNotifier) NotifyGatewayConfigStatus added in v3.4.3

func (c *ConfigStatusNotifier) NotifyGatewayConfigStatus(_ context.Context, status clients.GatewayConfigApplyStatus)

func (*ConfigStatusNotifier) NotifyKonnectConfigStatus added in v3.4.3

func (c *ConfigStatusNotifier) NotifyKonnectConfigStatus(_ context.Context, status clients.KonnectConfigUploadStatus)

type ConfigurationChangeDetector added in v3.4.3

type ConfigurationChangeDetector struct {
	ConfigurationChanged bool
}

ConfigurationChangeDetector is a mock implementation of sendconfig.ConfigurationChangeDetector.

func (ConfigurationChangeDetector) HasConfigurationChanged added in v3.4.3

func (m ConfigurationChangeDetector) HasConfigurationChanged(
	context.Context, []byte, []byte, *file.Content, sendconfig.StatusClient,
) (bool, error)

type Dataplane

type Dataplane struct {
	KubernetesObjectReportsEnabled bool
	// Mapping namespace to name to status
	// Note: this will come in useful when implementing
	// https://github.com/Kong/kubernetes-ingress-controller/issues/3793
	// which requires the status to be reported for route objects.
	ObjectsStatuses map[string]map[string]k8sobj.ConfigurationStatus
}

func (Dataplane) AreKubernetesObjectReportsEnabled

func (d Dataplane) AreKubernetesObjectReportsEnabled() bool

func (Dataplane) DeleteObject

func (d Dataplane) DeleteObject(_ client.Object) error

func (Dataplane) KubernetesObjectConfigurationStatus

func (d Dataplane) KubernetesObjectConfigurationStatus(obj client.Object) k8sobj.ConfigurationStatus

func (Dataplane) KubernetesObjectIsConfigured

func (d Dataplane) KubernetesObjectIsConfigured(obj client.Object) bool

func (Dataplane) Listeners

func (Dataplane) ObjectExists

func (d Dataplane) ObjectExists(obj client.Object) (bool, error)

func (Dataplane) UpdateObject

func (d Dataplane) UpdateObject(_ client.Object) error

type EventRecorder

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

EventRecorder is a mock implementation of the k8s.io/client-go/tools/record.EventRecorder interface.

func NewEventRecorder

func NewEventRecorder() *EventRecorder

func (*EventRecorder) AnnotatedEventf

func (r *EventRecorder) AnnotatedEventf(o runtime.Object, _ map[string]string, eventtype, reason, messageFmt string, args ...interface{})

func (*EventRecorder) Event

func (r *EventRecorder) Event(o runtime.Object, eventtype, reason, message string)

func (*EventRecorder) Eventf

func (r *EventRecorder) Eventf(o runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

func (*EventRecorder) Events

func (r *EventRecorder) Events() []string

type KonnectClientFactory added in v3.4.3

type KonnectClientFactory struct {
	Client *adminapi.KonnectClient
}

KonnectClientFactory is a mock implementation of konnect.ClientFactory.

func (*KonnectClientFactory) NewKonnectClient added in v3.4.3

type KonnectKongStateUpdater added in v3.4.3

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

KonnectKongStateUpdater is a mock implementation of dataplane.KonnectKongStateUpdater.

func (*KonnectKongStateUpdater) Calls added in v3.4.3

func (*KonnectKongStateUpdater) UpdateKongState added in v3.4.3

func (k *KonnectKongStateUpdater) UpdateKongState(kongState *kongstate.KongState, isFallback bool)

type KonnectKongStateUpdaterCall added in v3.4.3

type KonnectKongStateUpdaterCall struct {
	KongState  *kongstate.KongState
	IsFallback bool
}

type MetricsRecorder added in v3.4.1

type MetricsRecorder struct{}

MetricsRecorder is a mock implementation of metrics.Recorder.

func (MetricsRecorder) RecordFallbackCacheGenerationDuration added in v3.4.1

func (m MetricsRecorder) RecordFallbackCacheGenerationDuration(time.Duration, error)

func (MetricsRecorder) RecordFallbackPushFailure added in v3.4.1

func (m MetricsRecorder) RecordFallbackPushFailure(metrics.Protocol, time.Duration, mo.Option[int], string, int, error)

func (MetricsRecorder) RecordFallbackPushSuccess added in v3.4.1

func (m MetricsRecorder) RecordFallbackPushSuccess(metrics.Protocol, time.Duration, mo.Option[int], string)

func (MetricsRecorder) RecordFallbackTranslationBrokenResources added in v3.4.1

func (m MetricsRecorder) RecordFallbackTranslationBrokenResources(int)

func (MetricsRecorder) RecordFallbackTranslationFailure added in v3.4.1

func (m MetricsRecorder) RecordFallbackTranslationFailure(time.Duration)

func (MetricsRecorder) RecordFallbackTranslationSuccess added in v3.4.1

func (m MetricsRecorder) RecordFallbackTranslationSuccess(time.Duration)

func (MetricsRecorder) RecordProcessedConfigSnapshotCacheHit added in v3.4.1

func (m MetricsRecorder) RecordProcessedConfigSnapshotCacheHit()

func (MetricsRecorder) RecordProcessedConfigSnapshotCacheMiss added in v3.4.1

func (m MetricsRecorder) RecordProcessedConfigSnapshotCacheMiss()

func (MetricsRecorder) RecordPushFailure added in v3.4.1

func (m MetricsRecorder) RecordPushFailure(metrics.Protocol, time.Duration, mo.Option[int], string, int, error)

func (MetricsRecorder) RecordPushSuccess added in v3.4.1

func (m MetricsRecorder) RecordPushSuccess(metrics.Protocol, time.Duration, mo.Option[int], string)

func (MetricsRecorder) RecordTranslationBrokenResources added in v3.4.1

func (m MetricsRecorder) RecordTranslationBrokenResources(int)

func (MetricsRecorder) RecordTranslationFailure added in v3.4.1

func (m MetricsRecorder) RecordTranslationFailure(time.Duration)

func (MetricsRecorder) RecordTranslationSuccess added in v3.4.1

func (m MetricsRecorder) RecordTranslationSuccess(time.Duration)

type Ticker

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

func NewTicker

func NewTicker() *Ticker

func (*Ticker) Add

func (t *Ticker) Add(d time.Duration)

func (*Ticker) Channel

func (t *Ticker) Channel() <-chan time.Time

func (*Ticker) Now

func (t *Ticker) Now() time.Time

func (*Ticker) Reset

func (t *Ticker) Reset(d time.Duration)

func (*Ticker) Stop

func (t *Ticker) Stop()

type UpdateStrategy added in v3.4.3

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

UpdateStrategy is a mock implementation of sendconfig.UpdateStrategy.

func (*UpdateStrategy) MetricsProtocol added in v3.4.3

func (m *UpdateStrategy) MetricsProtocol() metrics.Protocol

func (*UpdateStrategy) Type added in v3.4.3

func (m *UpdateStrategy) Type() string

func (*UpdateStrategy) Update added in v3.4.3

func (m *UpdateStrategy) Update(_ context.Context, targetContent sendconfig.ContentWithHash) (n mo.Option[int], err error)

type UpdateStrategyResolver added in v3.4.3

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

UpdateStrategyResolver is a mock implementation of sendconfig.UpdateStrategyResolver.

func NewUpdateStrategyResolver added in v3.4.3

func NewUpdateStrategyResolver() *UpdateStrategyResolver

func (*UpdateStrategyResolver) AssertNoUpdateCalled added in v3.4.3

func (f *UpdateStrategyResolver) AssertNoUpdateCalled(t *testing.T)

AssertNoUpdateCalled asserts that no Update was not called.

func (*UpdateStrategyResolver) AssertUpdateCalledForURLs added in v3.4.3

func (f *UpdateStrategyResolver) AssertUpdateCalledForURLs(t *testing.T, urls []string, msgAndArgs ...any)

AssertUpdateCalledForURLs asserts that the mockUpdateStrategy was called for the given URLs.

func (*UpdateStrategyResolver) AssertUpdateCalledForURLsWithGivenCount added in v3.4.3

func (f *UpdateStrategyResolver) AssertUpdateCalledForURLsWithGivenCount(t *testing.T, urlToCount map[string]int, msgAndArgs ...any)

AssertUpdateCalledForURLsWithGivenCount asserts that Update was called for the given URLs with the given count.

func (*UpdateStrategyResolver) EventuallyGetLastUpdatedContentForURL added in v3.4.3

func (f *UpdateStrategyResolver) EventuallyGetLastUpdatedContentForURL(
	t *testing.T, url string, waitTime, waitTick time.Duration, msgAndArgs ...any,
) sendconfig.ContentWithHash

EventuallyGetLastUpdatedContentForURL waits for the given URL to be called and returns the last updated content.

func (*UpdateStrategyResolver) GetUpdateCalledForURLs added in v3.4.3

func (f *UpdateStrategyResolver) GetUpdateCalledForURLs() []string

GetUpdateCalledForURLs returns the called URLs.

func (*UpdateStrategyResolver) LastUpdatedContentForURL added in v3.4.3

func (f *UpdateStrategyResolver) LastUpdatedContentForURL(url string) (sendconfig.ContentWithHash, bool)

LastUpdatedContentForURL returns the last updated content for the given URL.

func (*UpdateStrategyResolver) ResolveUpdateStrategy added in v3.4.3

ResolveUpdateStrategy returns a mocked UpdateStrategy that will track which URLs were called.

func (*UpdateStrategyResolver) ReturnErrorOnUpdate added in v3.4.3

func (f *UpdateStrategyResolver) ReturnErrorOnUpdate(url string)

ReturnErrorOnUpdate will cause the mockUpdateStrategy with a given Admin API URL to return an error on Update(). Errors will be returned following FIFO order. Each call to this function adds a new error to the queue.

func (*UpdateStrategyResolver) ReturnSpecificErrorOnUpdate added in v3.4.3

func (f *UpdateStrategyResolver) ReturnSpecificErrorOnUpdate(url string, err error)

ReturnSpecificErrorOnUpdate will cause the mockUpdateStrategy with a given Admin API URL to return a specific error on Update() call. Errors will be returned following FIFO order. Each call to this function adds a new error to the queue.

Jump to

Keyboard shortcuts

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