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

@@ -27,7 +27,6 @@ import (
"time"
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
"go.uber.org/mock/gomock"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/stretchr/testify/assert"
@@ -177,17 +176,13 @@ func TestSoftRequirementsValidationSuccess(t *testing.T) {
func TestGetCapacity(t *testing.T) {
ephemeralStorageFromCapacity := int64(2000)
ephemeralStorageFromCadvisor := int64(8000)
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
mockCtrlError := gomock.NewController(t)
defer mockCtrlError.Finish()
mockCadvisor := cadvisortest.NewMockInterface(mockCtrl)
mockCadvisor := cadvisortest.NewMockInterface(t)
rootfs := cadvisorapiv2.FsInfo{
Capacity: 8000,
}
mockCadvisor.EXPECT().RootFsInfo().Return(rootfs, nil)
mockCadvisorError := cadvisortest.NewMockInterface(mockCtrlError)
mockCadvisorError := cadvisortest.NewMockInterface(t)
mockCadvisorError.EXPECT().RootFsInfo().Return(cadvisorapiv2.FsInfo{}, errors.New("Unable to get rootfs data from cAdvisor interface"))
cases := []struct {
name string