From 3b7528fd145eb67447563a7f7170ae3370ecb317 Mon Sep 17 00:00:00 2001 From: ralikio <74771103+ralikio@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:55:53 +0200 Subject: [PATCH 01/11] Bindings Mock --- internal/storage/automock/bindings.go | 123 ++++++++++++++++++++++++++ internal/storage/ext.go | 1 + 2 files changed, 124 insertions(+) create mode 100644 internal/storage/automock/bindings.go diff --git a/internal/storage/automock/bindings.go b/internal/storage/automock/bindings.go new file mode 100644 index 0000000000..f1dabbae94 --- /dev/null +++ b/internal/storage/automock/bindings.go @@ -0,0 +1,123 @@ +// Code generated by mockery v2.46.2. DO NOT EDIT. + +package mocks + +import ( + internal "github.com/kyma-project/kyma-environment-broker/internal" + mock "github.com/stretchr/testify/mock" +) + +// Bindings is an autogenerated mock type for the Bindings type +type Bindings struct { + mock.Mock +} + +// Delete provides a mock function with given fields: instanceID, bindingID +func (_m *Bindings) Delete(instanceID string, bindingID string) error { + ret := _m.Called(instanceID, bindingID) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(instanceID, bindingID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Get provides a mock function with given fields: instanceID, bindingID +func (_m *Bindings) Get(instanceID string, bindingID string) (*internal.Binding, error) { + ret := _m.Called(instanceID, bindingID) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *internal.Binding + var r1 error + if rf, ok := ret.Get(0).(func(string, string) (*internal.Binding, error)); ok { + return rf(instanceID, bindingID) + } + if rf, ok := ret.Get(0).(func(string, string) *internal.Binding); ok { + r0 = rf(instanceID, bindingID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*internal.Binding) + } + } + + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(instanceID, bindingID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Insert provides a mock function with given fields: binding +func (_m *Bindings) Insert(binding *internal.Binding) error { + ret := _m.Called(binding) + + if len(ret) == 0 { + panic("no return value specified for Insert") + } + + var r0 error + if rf, ok := ret.Get(0).(func(*internal.Binding) error); ok { + r0 = rf(binding) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ListByInstanceID provides a mock function with given fields: instanceID +func (_m *Bindings) ListByInstanceID(instanceID string) ([]internal.Binding, error) { + ret := _m.Called(instanceID) + + if len(ret) == 0 { + panic("no return value specified for ListByInstanceID") + } + + var r0 []internal.Binding + var r1 error + if rf, ok := ret.Get(0).(func(string) ([]internal.Binding, error)); ok { + return rf(instanceID) + } + if rf, ok := ret.Get(0).(func(string) []internal.Binding); ok { + r0 = rf(instanceID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]internal.Binding) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(instanceID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewBindings creates a new instance of Bindings. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewBindings(t interface { + mock.TestingT + Cleanup(func()) +}) *Bindings { + mock := &Bindings{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/storage/ext.go b/internal/storage/ext.go index 7b82921e12..d5aa3fb441 100644 --- a/internal/storage/ext.go +++ b/internal/storage/ext.go @@ -128,6 +128,7 @@ type SubaccountStates interface { ListStates() ([]internal.SubaccountState, error) } +//go:generate mockery --name=Bindings --output=automock --case=underscore type Bindings interface { Insert(binding *internal.Binding) error Get(instanceID string, bindingID string) (*internal.Binding, error) From 6b4b0f8778e2ad1f6dd6c9cf99d428382c2e95f8 Mon Sep 17 00:00:00 2001 From: ralikio <74771103+ralikio@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:33:18 +0200 Subject: [PATCH 02/11] 404 on Expired Bindings --- internal/broker/bind_get.go | 6 +++++ internal/broker/bind_get_test.go | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 internal/broker/bind_get_test.go diff --git a/internal/broker/bind_get.go b/internal/broker/bind_get.go index 190320d858..e7a3b5ef68 100644 --- a/internal/broker/bind_get.go +++ b/internal/broker/bind_get.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net/http" + "time" "github.com/kyma-project/kyma-environment-broker/internal/storage" "github.com/pivotal-cf/brokerapi/v8/domain" @@ -34,6 +35,11 @@ func (b *GetBindingEndpoint) GetBinding(_ context.Context, instanceID, bindingID return domain.GetBindingSpec{}, apiresponses.NewFailureResponse(fmt.Errorf(message), http.StatusNotFound, message) } + if binding.ExpiresAt.Before(time.Now()) { + message := "Binding expired" + return domain.GetBindingSpec{}, apiresponses.NewFailureResponse(fmt.Errorf(message), http.StatusNotFound, message) + } + if err != nil { b.log.Errorf("GetBinding error: %s", err) message := fmt.Sprintf("Unexpected error: %s", err) diff --git a/internal/broker/bind_get_test.go b/internal/broker/bind_get_test.go new file mode 100644 index 0000000000..54385b248f --- /dev/null +++ b/internal/broker/bind_get_test.go @@ -0,0 +1,44 @@ +package broker + +import ( + "context" + "net/http" + "testing" + "time" + + "github.com/kyma-project/kyma-environment-broker/internal" + mocks "github.com/kyma-project/kyma-environment-broker/internal/storage/automock" + "github.com/pivotal-cf/brokerapi/v8/domain" + "github.com/pivotal-cf/brokerapi/v8/domain/apiresponses" + "github.com/sirupsen/logrus" + "github.com/stretchr/testify/require" +) + +func TestGetBinding(t *testing.T) { + + t.Run("should return 404 code for the expired binding", func(t *testing.T) { + // given + mockBindings := new(mocks.Bindings) + + expiredBinding := &internal.Binding{ + ExpiresAt: time.Now().Add(-1 * time.Hour), + } + + mockBindings.On("Get", "test-instance-id", "test-binding-id").Return(expiredBinding, nil) + + endpoint := &GetBindingEndpoint{ + bindings: mockBindings, + log: &logrus.Logger{}, // Assuming you have a mock logger + } + + // when + _, err := endpoint.GetBinding(context.Background(), "test-instance-id", "test-binding-id", domain.FetchBindingDetails{}) + + // then + require.NotNil(t, err) + apiErr, ok := err.(*apiresponses.FailureResponse) + require.True(t, ok) + require.Equal(t, http.StatusNotFound, apiErr.ValidatedStatusCode(nil)) + mockBindings.AssertExpectations(t) + }) +} From 23488c5123e5671a5194bfa9ce0be995de76159a Mon Sep 17 00:00:00 2001 From: ralikio <74771103+ralikio@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:24:10 +0200 Subject: [PATCH 03/11] Review Remarks - https://github.com/kyma-project/kyma-environment-broker/pull/1355#discussion_r1804846107 --- internal/broker/bind_get_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/broker/bind_get_test.go b/internal/broker/bind_get_test.go index 54385b248f..1ce03cef45 100644 --- a/internal/broker/bind_get_test.go +++ b/internal/broker/bind_get_test.go @@ -39,6 +39,9 @@ func TestGetBinding(t *testing.T) { apiErr, ok := err.(*apiresponses.FailureResponse) require.True(t, ok) require.Equal(t, http.StatusNotFound, apiErr.ValidatedStatusCode(nil)) + + errorResponse := apiErr.ErrorResponse().(apiresponses.ErrorResponse) + require.Equal(t, "Binding expired", errorResponse.Description) mockBindings.AssertExpectations(t) }) } From 5deaec52310ca4f41781360cf1b04d350b355b3d Mon Sep 17 00:00:00 2001 From: ralikio <74771103+ralikio@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:26:04 +0200 Subject: [PATCH 04/11] Linter --- internal/broker/bind_get_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/broker/bind_get_test.go b/internal/broker/bind_get_test.go index 1ce03cef45..73ffd9f70b 100644 --- a/internal/broker/bind_get_test.go +++ b/internal/broker/bind_get_test.go @@ -39,9 +39,9 @@ func TestGetBinding(t *testing.T) { apiErr, ok := err.(*apiresponses.FailureResponse) require.True(t, ok) require.Equal(t, http.StatusNotFound, apiErr.ValidatedStatusCode(nil)) - - errorResponse := apiErr.ErrorResponse().(apiresponses.ErrorResponse) - require.Equal(t, "Binding expired", errorResponse.Description) + + errorResponse := apiErr.ErrorResponse().(apiresponses.ErrorResponse) + require.Equal(t, "Binding expired", errorResponse.Description) mockBindings.AssertExpectations(t) }) } From 900f24ae1d5cc8a13f6a05894ff5b1416bf38fe7 Mon Sep 17 00:00:00 2001 From: ralikio <74771103+ralikio@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:32:09 +0200 Subject: [PATCH 05/11] Test Adding New Method --- internal/storage/automock/bindings.go | 30 ++++++++++++++++++++++ internal/storage/driver/memory/binding.go | 15 +++++++++++ internal/storage/driver/postsql/binding.go | 20 +++++++++++++++ internal/storage/ext.go | 1 + 4 files changed, 66 insertions(+) diff --git a/internal/storage/automock/bindings.go b/internal/storage/automock/bindings.go index f1dabbae94..7c0e877035 100644 --- a/internal/storage/automock/bindings.go +++ b/internal/storage/automock/bindings.go @@ -60,6 +60,36 @@ func (_m *Bindings) Get(instanceID string, bindingID string) (*internal.Binding, return r0, r1 } +// Get2 provides a mock function with given fields: instanceID, bindingID +func (_m *Bindings) Get2(instanceID string, bindingID string) (*internal.Binding, error) { + ret := _m.Called(instanceID, bindingID) + + if len(ret) == 0 { + panic("no return value specified for Get2") + } + + var r0 *internal.Binding + var r1 error + if rf, ok := ret.Get(0).(func(string, string) (*internal.Binding, error)); ok { + return rf(instanceID, bindingID) + } + if rf, ok := ret.Get(0).(func(string, string) *internal.Binding); ok { + r0 = rf(instanceID, bindingID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*internal.Binding) + } + } + + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(instanceID, bindingID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // Insert provides a mock function with given fields: binding func (_m *Bindings) Insert(binding *internal.Binding) error { ret := _m.Called(binding) diff --git a/internal/storage/driver/memory/binding.go b/internal/storage/driver/memory/binding.go index 678007ee5b..2e4cc063e8 100644 --- a/internal/storage/driver/memory/binding.go +++ b/internal/storage/driver/memory/binding.go @@ -75,3 +75,18 @@ func (s *Binding) Get(instanceID string, bindingID string) (*internal.Binding, e return nil, dberr.NotFound("binding with id %s does not exist for given instance ID", bindingID) } } + +func (s *Binding) Get2(instanceID string, bindingID string) (*internal.Binding, error) { + s.mu.Lock() + defer s.mu.Unlock() + + binding, ok := s.data[bindingID] + if ok && binding.InstanceID == instanceID { + return &binding, nil + } else if !ok { + return nil, dberr.NotFound("binding with id %s does not exist", bindingID) + } else { + return nil, dberr.NotFound("binding with id %s does not exist for given instance ID", bindingID) + } +} + diff --git a/internal/storage/driver/postsql/binding.go b/internal/storage/driver/postsql/binding.go index 982885039d..0dd0365437 100644 --- a/internal/storage/driver/postsql/binding.go +++ b/internal/storage/driver/postsql/binding.go @@ -41,6 +41,26 @@ func (s *Binding) Get(instanceID string, bindingID string) (*internal.Binding, e return &binding, nil } +func (s *Binding) Get2(instanceID string, bindingID string) (*internal.Binding, error) { + sess := s.NewReadSession() + bindingDTO := dbmodel.BindingDTO{} + bindingDTO, dbErr := sess.GetBinding(instanceID, bindingID) + if dbErr != nil { + if dberr.IsNotFound(dbErr) { + return nil, dberr.NotFound("Binding with id %s does not exist", bindingID) + } + + return nil, fmt.Errorf("while getting bindingDTO by ID %s: %w", bindingID, dbErr) + } + + binding, err := s.toBinding(bindingDTO) + if err != nil { + return nil, err + } + + return &binding, nil +} + func (s *Binding) Insert(binding *internal.Binding) error { dto, err := s.toBindingDTO(binding) if err != nil { diff --git a/internal/storage/ext.go b/internal/storage/ext.go index d5aa3fb441..d75759b1bc 100644 --- a/internal/storage/ext.go +++ b/internal/storage/ext.go @@ -132,6 +132,7 @@ type SubaccountStates interface { type Bindings interface { Insert(binding *internal.Binding) error Get(instanceID string, bindingID string) (*internal.Binding, error) + Get2(instanceID string, bindingID string) (*internal.Binding, error) ListByInstanceID(instanceID string) ([]internal.Binding, error) Delete(instanceID, bindingID string) error } From afb3b56d22d1ff62172b4a5caba236bc5ba68d8a Mon Sep 17 00:00:00 2001 From: ralikio <74771103+ralikio@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:46:00 +0200 Subject: [PATCH 06/11] Review Remarks --- internal/broker/bind_get_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/broker/bind_get_test.go b/internal/broker/bind_get_test.go index 73ffd9f70b..0d4d93dbba 100644 --- a/internal/broker/bind_get_test.go +++ b/internal/broker/bind_get_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/kyma-project/kyma-environment-broker/internal" - mocks "github.com/kyma-project/kyma-environment-broker/internal/storage/automock" + "github.com/kyma-project/kyma-environment-broker/internal/storage/driver/memory" "github.com/pivotal-cf/brokerapi/v8/domain" "github.com/pivotal-cf/brokerapi/v8/domain/apiresponses" "github.com/sirupsen/logrus" @@ -18,17 +18,18 @@ func TestGetBinding(t *testing.T) { t.Run("should return 404 code for the expired binding", func(t *testing.T) { // given - mockBindings := new(mocks.Bindings) + bindingsMemory := memory.NewBinding() expiredBinding := &internal.Binding{ + ID: "test-binding-id", + InstanceID: "test-instance-id", ExpiresAt: time.Now().Add(-1 * time.Hour), } - - mockBindings.On("Get", "test-instance-id", "test-binding-id").Return(expiredBinding, nil) + bindingsMemory.Insert(expiredBinding) endpoint := &GetBindingEndpoint{ - bindings: mockBindings, - log: &logrus.Logger{}, // Assuming you have a mock logger + bindings: bindingsMemory, + log: &logrus.Logger{}, } // when @@ -42,6 +43,5 @@ func TestGetBinding(t *testing.T) { errorResponse := apiErr.ErrorResponse().(apiresponses.ErrorResponse) require.Equal(t, "Binding expired", errorResponse.Description) - mockBindings.AssertExpectations(t) }) } From 2f2bc0b1d469816d0e4e2cefdf7e39029baade81 Mon Sep 17 00:00:00 2001 From: ralikio <74771103+ralikio@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:55:56 +0200 Subject: [PATCH 07/11] Linter & Error Correction --- internal/broker/bind_get_test.go | 11 ++++++----- internal/storage/driver/memory/binding.go | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/broker/bind_get_test.go b/internal/broker/bind_get_test.go index 0d4d93dbba..3e2ab98a13 100644 --- a/internal/broker/bind_get_test.go +++ b/internal/broker/bind_get_test.go @@ -21,19 +21,20 @@ func TestGetBinding(t *testing.T) { bindingsMemory := memory.NewBinding() expiredBinding := &internal.Binding{ - ID: "test-binding-id", + ID: "test-binding-id", InstanceID: "test-instance-id", - ExpiresAt: time.Now().Add(-1 * time.Hour), + ExpiresAt: time.Now().Add(-1 * time.Hour), } - bindingsMemory.Insert(expiredBinding) + err := bindingsMemory.Insert(expiredBinding) + require.NoError(t, err) endpoint := &GetBindingEndpoint{ bindings: bindingsMemory, - log: &logrus.Logger{}, + log: &logrus.Logger{}, } // when - _, err := endpoint.GetBinding(context.Background(), "test-instance-id", "test-binding-id", domain.FetchBindingDetails{}) + _, err = endpoint.GetBinding(context.Background(), "test-instance-id", "test-binding-id", domain.FetchBindingDetails{}) // then require.NotNil(t, err) diff --git a/internal/storage/driver/memory/binding.go b/internal/storage/driver/memory/binding.go index 2e4cc063e8..8198f83f59 100644 --- a/internal/storage/driver/memory/binding.go +++ b/internal/storage/driver/memory/binding.go @@ -89,4 +89,3 @@ func (s *Binding) Get2(instanceID string, bindingID string) (*internal.Binding, return nil, dberr.NotFound("binding with id %s does not exist for given instance ID", bindingID) } } - From c84dc560c7270e19aea8a944be925f9b8ede7198 Mon Sep 17 00:00:00 2001 From: Wojciech Wrzalik <74771103+ralikio@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:13:23 +0200 Subject: [PATCH 08/11] Update ext.go --- internal/storage/ext.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/storage/ext.go b/internal/storage/ext.go index d75759b1bc..7b82921e12 100644 --- a/internal/storage/ext.go +++ b/internal/storage/ext.go @@ -128,11 +128,9 @@ type SubaccountStates interface { ListStates() ([]internal.SubaccountState, error) } -//go:generate mockery --name=Bindings --output=automock --case=underscore type Bindings interface { Insert(binding *internal.Binding) error Get(instanceID string, bindingID string) (*internal.Binding, error) - Get2(instanceID string, bindingID string) (*internal.Binding, error) ListByInstanceID(instanceID string) ([]internal.Binding, error) Delete(instanceID, bindingID string) error } From a67d8031630fffa101294529d3dd1b309d23d321 Mon Sep 17 00:00:00 2001 From: Wojciech Wrzalik <74771103+ralikio@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:13:58 +0200 Subject: [PATCH 09/11] Update binding.go --- internal/storage/driver/postsql/binding.go | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/internal/storage/driver/postsql/binding.go b/internal/storage/driver/postsql/binding.go index 0dd0365437..982885039d 100644 --- a/internal/storage/driver/postsql/binding.go +++ b/internal/storage/driver/postsql/binding.go @@ -41,26 +41,6 @@ func (s *Binding) Get(instanceID string, bindingID string) (*internal.Binding, e return &binding, nil } -func (s *Binding) Get2(instanceID string, bindingID string) (*internal.Binding, error) { - sess := s.NewReadSession() - bindingDTO := dbmodel.BindingDTO{} - bindingDTO, dbErr := sess.GetBinding(instanceID, bindingID) - if dbErr != nil { - if dberr.IsNotFound(dbErr) { - return nil, dberr.NotFound("Binding with id %s does not exist", bindingID) - } - - return nil, fmt.Errorf("while getting bindingDTO by ID %s: %w", bindingID, dbErr) - } - - binding, err := s.toBinding(bindingDTO) - if err != nil { - return nil, err - } - - return &binding, nil -} - func (s *Binding) Insert(binding *internal.Binding) error { dto, err := s.toBindingDTO(binding) if err != nil { From c5234f71f892fb580a31ebb50a5d54958d6f6e04 Mon Sep 17 00:00:00 2001 From: Wojciech Wrzalik <74771103+ralikio@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:14:21 +0200 Subject: [PATCH 10/11] Update binding.go --- internal/storage/driver/memory/binding.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/internal/storage/driver/memory/binding.go b/internal/storage/driver/memory/binding.go index 8198f83f59..678007ee5b 100644 --- a/internal/storage/driver/memory/binding.go +++ b/internal/storage/driver/memory/binding.go @@ -75,17 +75,3 @@ func (s *Binding) Get(instanceID string, bindingID string) (*internal.Binding, e return nil, dberr.NotFound("binding with id %s does not exist for given instance ID", bindingID) } } - -func (s *Binding) Get2(instanceID string, bindingID string) (*internal.Binding, error) { - s.mu.Lock() - defer s.mu.Unlock() - - binding, ok := s.data[bindingID] - if ok && binding.InstanceID == instanceID { - return &binding, nil - } else if !ok { - return nil, dberr.NotFound("binding with id %s does not exist", bindingID) - } else { - return nil, dberr.NotFound("binding with id %s does not exist for given instance ID", bindingID) - } -} From 1afb35f991fd4139d88d28ff6168a269c83a490d Mon Sep 17 00:00:00 2001 From: Wojciech Wrzalik <74771103+ralikio@users.noreply.github.com> Date: Fri, 18 Oct 2024 12:14:46 +0200 Subject: [PATCH 11/11] Delete internal/storage/automock/bindings.go --- internal/storage/automock/bindings.go | 153 -------------------------- 1 file changed, 153 deletions(-) delete mode 100644 internal/storage/automock/bindings.go diff --git a/internal/storage/automock/bindings.go b/internal/storage/automock/bindings.go deleted file mode 100644 index 7c0e877035..0000000000 --- a/internal/storage/automock/bindings.go +++ /dev/null @@ -1,153 +0,0 @@ -// Code generated by mockery v2.46.2. DO NOT EDIT. - -package mocks - -import ( - internal "github.com/kyma-project/kyma-environment-broker/internal" - mock "github.com/stretchr/testify/mock" -) - -// Bindings is an autogenerated mock type for the Bindings type -type Bindings struct { - mock.Mock -} - -// Delete provides a mock function with given fields: instanceID, bindingID -func (_m *Bindings) Delete(instanceID string, bindingID string) error { - ret := _m.Called(instanceID, bindingID) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if rf, ok := ret.Get(0).(func(string, string) error); ok { - r0 = rf(instanceID, bindingID) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Get provides a mock function with given fields: instanceID, bindingID -func (_m *Bindings) Get(instanceID string, bindingID string) (*internal.Binding, error) { - ret := _m.Called(instanceID, bindingID) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *internal.Binding - var r1 error - if rf, ok := ret.Get(0).(func(string, string) (*internal.Binding, error)); ok { - return rf(instanceID, bindingID) - } - if rf, ok := ret.Get(0).(func(string, string) *internal.Binding); ok { - r0 = rf(instanceID, bindingID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*internal.Binding) - } - } - - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(instanceID, bindingID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Get2 provides a mock function with given fields: instanceID, bindingID -func (_m *Bindings) Get2(instanceID string, bindingID string) (*internal.Binding, error) { - ret := _m.Called(instanceID, bindingID) - - if len(ret) == 0 { - panic("no return value specified for Get2") - } - - var r0 *internal.Binding - var r1 error - if rf, ok := ret.Get(0).(func(string, string) (*internal.Binding, error)); ok { - return rf(instanceID, bindingID) - } - if rf, ok := ret.Get(0).(func(string, string) *internal.Binding); ok { - r0 = rf(instanceID, bindingID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*internal.Binding) - } - } - - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(instanceID, bindingID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Insert provides a mock function with given fields: binding -func (_m *Bindings) Insert(binding *internal.Binding) error { - ret := _m.Called(binding) - - if len(ret) == 0 { - panic("no return value specified for Insert") - } - - var r0 error - if rf, ok := ret.Get(0).(func(*internal.Binding) error); ok { - r0 = rf(binding) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// ListByInstanceID provides a mock function with given fields: instanceID -func (_m *Bindings) ListByInstanceID(instanceID string) ([]internal.Binding, error) { - ret := _m.Called(instanceID) - - if len(ret) == 0 { - panic("no return value specified for ListByInstanceID") - } - - var r0 []internal.Binding - var r1 error - if rf, ok := ret.Get(0).(func(string) ([]internal.Binding, error)); ok { - return rf(instanceID) - } - if rf, ok := ret.Get(0).(func(string) []internal.Binding); ok { - r0 = rf(instanceID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]internal.Binding) - } - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(instanceID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// NewBindings creates a new instance of Bindings. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewBindings(t interface { - mock.TestingT - Cleanup(func()) -}) *Bindings { - mock := &Bindings{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -}