Switch to stretchr/testify / mockery for mocks

testify is used throughout the codebase; this switches mocks from
gomock to testify with the help of mockery for code generation.

Handlers and mocks in test/utils/oidc are moved to a new package:
mockery operates package by package, and requires packages to build
correctly; test/utils/oidc/testserver.go relies on the mocks and fails
to build when they are removed. Moving the interface and mocks to a
different package allows mockery to process that package without
having to build testserver.go.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
This commit is contained in:
Stephen Kitt
2024-06-04 19:29:42 +02:00
parent 78377c4d10
commit 3f36c83c68
97 changed files with 12593 additions and 5640 deletions

View File

@@ -0,0 +1,119 @@
/*
Copyright The Kubernetes Authors.
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.
*/
/*
Copyright The Kubernetes Authors.
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 mockery v2.40.3. DO NOT EDIT.
package handlers
import mock "github.com/stretchr/testify/mock"
// MockTokenHandler is an autogenerated mock type for the TokenHandler type
type MockTokenHandler struct {
mock.Mock
}
type MockTokenHandler_Expecter struct {
mock *mock.Mock
}
func (_m *MockTokenHandler) EXPECT() *MockTokenHandler_Expecter {
return &MockTokenHandler_Expecter{mock: &_m.Mock}
}
// Token provides a mock function with given fields:
func (_m *MockTokenHandler) Token() (Token, error) {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for Token")
}
var r0 Token
var r1 error
if rf, ok := ret.Get(0).(func() (Token, error)); ok {
return rf()
}
if rf, ok := ret.Get(0).(func() Token); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(Token)
}
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockTokenHandler_Token_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Token'
type MockTokenHandler_Token_Call struct {
*mock.Call
}
// Token is a helper method to define mock.On call
func (_e *MockTokenHandler_Expecter) Token() *MockTokenHandler_Token_Call {
return &MockTokenHandler_Token_Call{Call: _e.mock.On("Token")}
}
func (_c *MockTokenHandler_Token_Call) Run(run func()) *MockTokenHandler_Token_Call {
_c.Call.Run(func(args mock.Arguments) {
run()
})
return _c
}
func (_c *MockTokenHandler_Token_Call) Return(_a0 Token, _a1 error) *MockTokenHandler_Token_Call {
_c.Call.Return(_a0, _a1)
return _c
}
func (_c *MockTokenHandler_Token_Call) RunAndReturn(run func() (Token, error)) *MockTokenHandler_Token_Call {
_c.Call.Return(run)
return _c
}
// NewMockTokenHandler creates a new instance of MockTokenHandler. 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 NewMockTokenHandler(t interface {
mock.TestingT
Cleanup(func())
}) *MockTokenHandler {
mock := &MockTokenHandler{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}