From 474cd61c66102b11e307d3f7216ccfaee452b0b8 Mon Sep 17 00:00:00 2001 From: Dawid Rusnak Date: Fri, 18 Oct 2024 13:53:00 +0200 Subject: [PATCH] feat: add interface for WebhooksClient --- pkg/client/executors/v1/mock_webhooks.go | 138 +++++++++++++++++++++++ pkg/client/executors/v1/webhooks.go | 12 ++ 2 files changed, 150 insertions(+) create mode 100644 pkg/client/executors/v1/mock_webhooks.go diff --git a/pkg/client/executors/v1/mock_webhooks.go b/pkg/client/executors/v1/mock_webhooks.go new file mode 100644 index 00000000..319fb06e --- /dev/null +++ b/pkg/client/executors/v1/mock_webhooks.go @@ -0,0 +1,138 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/kubeshop/testkube-operator/pkg/client/executors/v1 (interfaces: WebhooksInterface) + +// Package executors is a generated GoMock package. +package executors + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + v1 "github.com/kubeshop/testkube-operator/api/executor/v1" +) + +// MockWebhooksInterface is a mock of WebhooksInterface interface. +type MockWebhooksInterface struct { + ctrl *gomock.Controller + recorder *MockWebhooksInterfaceMockRecorder +} + +// MockWebhooksInterfaceMockRecorder is the mock recorder for MockWebhooksInterface. +type MockWebhooksInterfaceMockRecorder struct { + mock *MockWebhooksInterface +} + +// NewMockWebhooksInterface creates a new mock instance. +func NewMockWebhooksInterface(ctrl *gomock.Controller) *MockWebhooksInterface { + mock := &MockWebhooksInterface{ctrl: ctrl} + mock.recorder = &MockWebhooksInterfaceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockWebhooksInterface) EXPECT() *MockWebhooksInterfaceMockRecorder { + return m.recorder +} + +// Create mocks base method. +func (m *MockWebhooksInterface) Create(arg0 *v1.Webhook) (*v1.Webhook, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Create", arg0) + ret0, _ := ret[0].(*v1.Webhook) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Create indicates an expected call of Create. +func (mr *MockWebhooksInterfaceMockRecorder) Create(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockWebhooksInterface)(nil).Create), arg0) +} + +// Delete mocks base method. +func (m *MockWebhooksInterface) Delete(arg0 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockWebhooksInterfaceMockRecorder) Delete(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockWebhooksInterface)(nil).Delete), arg0) +} + +// DeleteByLabels mocks base method. +func (m *MockWebhooksInterface) DeleteByLabels(arg0 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteByLabels", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteByLabels indicates an expected call of DeleteByLabels. +func (mr *MockWebhooksInterfaceMockRecorder) DeleteByLabels(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteByLabels", reflect.TypeOf((*MockWebhooksInterface)(nil).DeleteByLabels), arg0) +} + +// Get mocks base method. +func (m *MockWebhooksInterface) Get(arg0 string) (*v1.Webhook, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Get", arg0) + ret0, _ := ret[0].(*v1.Webhook) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get. +func (mr *MockWebhooksInterfaceMockRecorder) Get(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockWebhooksInterface)(nil).Get), arg0) +} + +// GetByEvent mocks base method. +func (m *MockWebhooksInterface) GetByEvent(arg0 v1.EventType) (*v1.WebhookList, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetByEvent", arg0) + ret0, _ := ret[0].(*v1.WebhookList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetByEvent indicates an expected call of GetByEvent. +func (mr *MockWebhooksInterfaceMockRecorder) GetByEvent(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByEvent", reflect.TypeOf((*MockWebhooksInterface)(nil).GetByEvent), arg0) +} + +// List mocks base method. +func (m *MockWebhooksInterface) List(arg0 string) (*v1.WebhookList, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "List", arg0) + ret0, _ := ret[0].(*v1.WebhookList) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockWebhooksInterfaceMockRecorder) List(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockWebhooksInterface)(nil).List), arg0) +} + +// Update mocks base method. +func (m *MockWebhooksInterface) Update(arg0 *v1.Webhook) (*v1.Webhook, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Update", arg0) + ret0, _ := ret[0].(*v1.Webhook) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Update indicates an expected call of Update. +func (mr *MockWebhooksInterfaceMockRecorder) Update(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockWebhooksInterface)(nil).Update), arg0) +} diff --git a/pkg/client/executors/v1/webhooks.go b/pkg/client/executors/v1/webhooks.go index 17173395..f464e060 100644 --- a/pkg/client/executors/v1/webhooks.go +++ b/pkg/client/executors/v1/webhooks.go @@ -5,12 +5,24 @@ import ( "fmt" executorsv1 "github.com/kubeshop/testkube-operator/api/executor/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/labels" "sigs.k8s.io/controller-runtime/pkg/client" ) +//go:generate mockgen -destination=./mock_webhooks.go -package=executors "github.com/kubeshop/testkube-operator/pkg/client/executors/v1" WebhooksInterface +type WebhooksInterface interface { + List(selector string) (*executorsv1.WebhookList, error) + Get(name string) (*executorsv1.Webhook, error) + GetByEvent(event executorsv1.EventType) (*executorsv1.WebhookList, error) + Create(webhook *executorsv1.Webhook) (*executorsv1.Webhook, error) + Update(webhook *executorsv1.Webhook) (*executorsv1.Webhook, error) + Delete(name string) error + DeleteByLabels(selector string) error +} + // NewWebhooksClient returns new client instance, needs kubernetes client to be passed as dependecy func NewWebhooksClient(client client.Client, namespace string) *WebhooksClient { return &WebhooksClient{