fake

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Overview

Copyright (c) Microsoft Corporation.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Code generated by MockGen. DO NOT EDIT. Source: pkg/providers/instance/azure_client.go

Generated by this command:

mockgen -source=pkg/providers/instance/azure_client.go -destination=pkg/fake/azure_client.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAgentPoolObjWithNodeClaim added in v0.3.0

func CreateAgentPoolObjWithNodeClaim(nc *karpenterv1.NodeClaim) armcontainerservice.AgentPool

func CreateNodeListWithNodeClaim added in v0.3.0

func CreateNodeListWithNodeClaim(nodeClaims []*karpenterv1.NodeClaim) *corev1.NodeList

func GetNodeClaimObj added in v0.3.0

func GetNodeClaimObj(name string, labels map[string]string, taints []v1.Taint, resource karpenterv1.ResourceRequirements, req []v1.NodeSelectorRequirement) *karpenterv1.NodeClaim

func GetNodeClaimObjWithoutProviderID added in v0.3.0

func GetNodeClaimObjWithoutProviderID(name string, labels map[string]string, taints []v1.Taint, resource karpenterv1.ResourceRequirements, req []v1.NodeSelectorRequirement) *karpenterv1.NodeClaim

Types

type AtomicError

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

func (*AtomicError) Get

func (e *AtomicError) Get() error

Get is equivalent to the error being called, so we increase number of calls in this function

func (*AtomicError) IsNil

func (e *AtomicError) IsNil() bool

func (*AtomicError) Reset

func (e *AtomicError) Reset()

func (*AtomicError) Set

func (e *AtomicError) Set(err error, opts ...AtomicErrorOption)

type AtomicErrorOption

type AtomicErrorOption func(atomicError *AtomicError)

func MaxCalls

func MaxCalls(maxCalls int) AtomicErrorOption

type AtomicPtr

type AtomicPtr[T any] struct {
	// contains filtered or unexported fields
}

AtomicPtr is intended for use in mocks to easily expose variables for use in testing. It makes setting and retrieving the values race free by wrapping the pointer itself in a mutex. There is no Get() method, but instead a Clone() method deep copies the object being stored by serializing/de-serializing it from JSON. This pattern shouldn't be followed anywhere else but is an easy way to eliminate races in our tests. nolint: structcheck

func (*AtomicPtr[T]) Clone

func (a *AtomicPtr[T]) Clone() *T

func (*AtomicPtr[T]) IsNil

func (a *AtomicPtr[T]) IsNil() bool

func (*AtomicPtr[T]) Reset

func (a *AtomicPtr[T]) Reset()

func (*AtomicPtr[T]) Set

func (a *AtomicPtr[T]) Set(v *T)

type AtomicPtrStack

type AtomicPtrStack[T any] struct {
	// contains filtered or unexported fields
}

AtomicPtrStack exposes a slice of a pointer type in a race-free manner. The interface is just enough to replace the set.Set usage in our previous tests. nolint: structcheck

func (*AtomicPtrStack[T]) Add

func (a *AtomicPtrStack[T]) Add(input *T)

func (*AtomicPtrStack[T]) Len

func (a *AtomicPtrStack[T]) Len() int

func (*AtomicPtrStack[T]) Pop

func (a *AtomicPtrStack[T]) Pop() *T

func (*AtomicPtrStack[T]) Reset

func (a *AtomicPtrStack[T]) Reset()

type MockAgentPoolsAPI added in v0.2.0

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

MockAgentPoolsAPI is a mock of AgentPoolsAPI interface.

func NewMockAgentPoolsAPI added in v0.2.0

func NewMockAgentPoolsAPI(ctrl *gomock.Controller) *MockAgentPoolsAPI

NewMockAgentPoolsAPI creates a new mock instance.

func (*MockAgentPoolsAPI) BeginCreateOrUpdate added in v0.2.0

func (m *MockAgentPoolsAPI) BeginCreateOrUpdate(ctx context.Context, resourceGroupName, resourceName, agentPoolName string, parameters armcontainerservice.AgentPool, options *armcontainerservice.AgentPoolsClientBeginCreateOrUpdateOptions) (*runtime.Poller[armcontainerservice.AgentPoolsClientCreateOrUpdateResponse], error)

BeginCreateOrUpdate mocks base method.

func (*MockAgentPoolsAPI) BeginDelete added in v0.2.0

func (m *MockAgentPoolsAPI) BeginDelete(ctx context.Context, resourceGroupName, resourceName, agentPoolName string, options *armcontainerservice.AgentPoolsClientBeginDeleteOptions) (*runtime.Poller[armcontainerservice.AgentPoolsClientDeleteResponse], error)

BeginDelete mocks base method.

func (*MockAgentPoolsAPI) EXPECT added in v0.2.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAgentPoolsAPI) Get added in v0.2.0

func (m *MockAgentPoolsAPI) Get(ctx context.Context, resourceGroupName, resourceName, agentPoolName string, options *armcontainerservice.AgentPoolsClientGetOptions) (armcontainerservice.AgentPoolsClientGetResponse, error)

Get mocks base method.

func (*MockAgentPoolsAPI) NewListPager added in v0.2.0

func (m *MockAgentPoolsAPI) NewListPager(resourceGroupName, resourceName string, options *armcontainerservice.AgentPoolsClientListOptions) *runtime.Pager[armcontainerservice.AgentPoolsClientListResponse]

NewListPager mocks base method.

type MockAgentPoolsAPIMockRecorder added in v0.2.0

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

MockAgentPoolsAPIMockRecorder is the mock recorder for MockAgentPoolsAPI.

func (*MockAgentPoolsAPIMockRecorder) BeginCreateOrUpdate added in v0.2.0

func (mr *MockAgentPoolsAPIMockRecorder) BeginCreateOrUpdate(ctx, resourceGroupName, resourceName, agentPoolName, parameters, options any) *gomock.Call

BeginCreateOrUpdate indicates an expected call of BeginCreateOrUpdate.

func (*MockAgentPoolsAPIMockRecorder) BeginDelete added in v0.2.0

func (mr *MockAgentPoolsAPIMockRecorder) BeginDelete(ctx, resourceGroupName, resourceName, agentPoolName, options any) *gomock.Call

BeginDelete indicates an expected call of BeginDelete.

func (*MockAgentPoolsAPIMockRecorder) Get added in v0.2.0

func (mr *MockAgentPoolsAPIMockRecorder) Get(ctx, resourceGroupName, resourceName, agentPoolName, options any) *gomock.Call

Get indicates an expected call of Get.

func (*MockAgentPoolsAPIMockRecorder) NewListPager added in v0.2.0

func (mr *MockAgentPoolsAPIMockRecorder) NewListPager(resourceGroupName, resourceName, options any) *gomock.Call

NewListPager indicates an expected call of NewListPager.

type MockClient added in v0.2.0

type MockClient struct {
	mock.Mock

	ObjectMap  map[reflect.Type]map[k8sClient.ObjectKey]k8sClient.Object
	StatusMock *MockStatusClient
	UpdateCb   func(key types.NamespacedName)
}

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

func NewClient added in v0.2.0

func NewClient() *MockClient

func (*MockClient) Create added in v0.2.0

func (m *MockClient) Create(ctx context.Context, obj k8sClient.Object, opts ...k8sClient.CreateOption) error

func (*MockClient) CreateMapWithType added in v0.2.0

func (m *MockClient) CreateMapWithType(t interface{}) map[k8sClient.ObjectKey]k8sClient.Object

func (*MockClient) CreateOrUpdateObjectInMap added in v0.2.0

func (m *MockClient) CreateOrUpdateObjectInMap(obj k8sClient.Object)

func (*MockClient) Delete added in v0.2.0

func (m *MockClient) Delete(ctx context.Context, obj k8sClient.Object, opts ...k8sClient.DeleteOption) error

func (*MockClient) DeleteAllOf added in v0.2.0

func (m *MockClient) DeleteAllOf(ctx context.Context, obj k8sClient.Object, opts ...k8sClient.DeleteAllOfOption) error

func (*MockClient) Get added in v0.2.0

k8s Client interface

func (*MockClient) GetObjectFromMap added in v0.2.0

func (m *MockClient) GetObjectFromMap(obj k8sClient.Object, key types.NamespacedName)

func (*MockClient) GroupVersionKindFor added in v0.2.0

func (m *MockClient) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error)

GroupVersionKindFor implements client.Client

func (*MockClient) IsObjectNamespaced added in v0.2.0

func (m *MockClient) IsObjectNamespaced(obj runtime.Object) (bool, error)

IsObjectNamespaced implements client.Client

func (*MockClient) List added in v0.2.0

func (*MockClient) Patch added in v0.2.0

func (m *MockClient) Patch(ctx context.Context, obj k8sClient.Object, patch k8sClient.Patch, opts ...k8sClient.PatchOption) error

func (*MockClient) RESTMapper added in v0.2.0

func (m *MockClient) RESTMapper() meta.RESTMapper

func (*MockClient) Scheme added in v0.2.0

func (m *MockClient) Scheme() *runtime.Scheme

func (*MockClient) Status added in v0.2.0

func (m *MockClient) Status() k8sClient.StatusWriter

StatusClient interface

func (*MockClient) SubResource added in v0.3.0

func (m *MockClient) SubResource(subResource string) k8sClient.SubResourceClient

SubResourceClientConstructor interface

func (*MockClient) Update added in v0.2.0

func (m *MockClient) Update(ctx context.Context, obj k8sClient.Object, opts ...k8sClient.UpdateOption) error

type MockHandler

type MockHandler[T any] struct {
	// contains filtered or unexported fields
}

MockHandler returns a pre-defined result or error. nolint: structcheck

func (MockHandler[T]) Done

func (h MockHandler[T]) Done() bool

Done returns true if the LRO has reached a terminal state. TrivialHanlder is always done.

func (MockHandler[T]) Poll

func (h MockHandler[T]) Poll(context.Context) (*http.Response, error)

Poll fetches the latest state of the LRO.

func (MockHandler[T]) Result

func (h MockHandler[T]) Result(_ context.Context, result *T) error

Result is called once the LRO has reached a terminal state. It populates the out parameter with the result of the operation.

type MockPollingHandler added in v0.2.0

type MockPollingHandler[T any] struct {
	// contains filtered or unexported fields
}

MockPollingHandler is a mock implementation of PollingHandler interface.

func NewMockPollingHandler added in v0.2.0

func NewMockPollingHandler[T any](ctrl *gomock.Controller) *MockPollingHandler[T]

NewMockPollingHandler creates a new mock instance.

func (*MockPollingHandler[T]) Done added in v0.2.0

func (m *MockPollingHandler[T]) Done() bool

Done mocks the Done method of the PollingHandler interface.

func (*MockPollingHandler[T]) EXPECT added in v0.2.0

EXPECT methods can be used to set up expected calls.

func (*MockPollingHandler[T]) Poll added in v0.2.0

func (m *MockPollingHandler[T]) Poll(ctx context.Context) (*http.Response, error)

Poll mocks the Poll method of the PollingHandler interface.

func (*MockPollingHandler[T]) Result added in v0.2.0

func (m *MockPollingHandler[T]) Result(ctx context.Context, out *T) error

Result mocks the Result method of the PollingHandler interface.

type MockPollingHandlerMockRecorder added in v0.2.0

type MockPollingHandlerMockRecorder[T any] struct {
	// contains filtered or unexported fields
}

MockPollingHandlerMockRecorder is the mock recorder for MockPollingHandler.

func (*MockPollingHandlerMockRecorder[T]) Done added in v0.2.0

func (*MockPollingHandlerMockRecorder[T]) Poll added in v0.2.0

func (mr *MockPollingHandlerMockRecorder[T]) Poll(ctx any) *gomock.Call

func (*MockPollingHandlerMockRecorder[T]) Result added in v0.2.0

func (mr *MockPollingHandlerMockRecorder[T]) Result(ctx, out any) *gomock.Call

type MockStatusClient added in v0.2.0

type MockStatusClient struct {
	mock.Mock
}

func (*MockStatusClient) Create added in v0.3.0

Create implements client.StatusWriter

func (*MockStatusClient) Get added in v0.3.0

func (*MockStatusClient) Patch added in v0.2.0

Patch implements client.StatusWriter

func (*MockStatusClient) Update added in v0.2.0

Update implements client.StatusWriter

type MockedFunction

type MockedFunction[I any, O any] struct {
	Output          AtomicPtr[O]      // Output to return on call to this function
	CalledWithInput AtomicPtrStack[I] // Stack used to keep track of passed input to this function
	Error           AtomicError       // Error to return a certain number of times defined by custom error options
	// contains filtered or unexported fields
}

func (*MockedFunction[I, O]) Calls

func (m *MockedFunction[I, O]) Calls() int

func (*MockedFunction[I, O]) FailedCalls

func (m *MockedFunction[I, O]) FailedCalls() int

func (*MockedFunction[I, O]) Invoke

func (m *MockedFunction[I, O]) Invoke(input *I, defaultTransformer func(*I) (O, error)) (O, error)

func (*MockedFunction[I, O]) Reset

func (m *MockedFunction[I, O]) Reset()

Reset must be called between tests otherwise tests will pollute each other.

func (*MockedFunction[I, O]) SuccessfulCalls

func (m *MockedFunction[I, O]) SuccessfulCalls() int

type MockedLRO

type MockedLRO[I any, O any] struct {
	MockedFunction[I, O]
	BeginError AtomicError // Error to return a certain number of times defined by custom error options (for Begin)
}

func (*MockedLRO[I, O]) Calls

func (m *MockedLRO[I, O]) Calls() int

func (*MockedLRO[I, O]) FailedCalls

func (m *MockedLRO[I, O]) FailedCalls() int

func (*MockedLRO[I, O]) Invoke

func (m *MockedLRO[I, O]) Invoke(input *I, defaultTransformer func(*I) (*O, error)) (*runtime.Poller[O], error)

func (*MockedLRO[I, O]) Reset

func (m *MockedLRO[I, O]) Reset()

Reset must be called between tests otherwise tests will pollute each other.

func (*MockedLRO[I, O]) SuccessfulCalls

func (m *MockedLRO[I, O]) SuccessfulCalls() int

Jump to

Keyboard shortcuts

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