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

@@ -26,8 +26,8 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env
echo 'installing mockgen'
go -C "${KUBE_ROOT}/hack/tools" install go.uber.org/mock/mockgen
echo 'installing mockery'
go -C "${KUBE_ROOT}/hack/tools" install github.com/vektra/mockery/v2
function git_grep() {
git grep --untracked --exclude-standard \
@@ -42,7 +42,7 @@ function git_grep() {
cd "${KUBE_ROOT}"
GENERATED_MOCK_FILE_REGEX="^// Code generated by MockGen. DO NOT EDIT.$"
GENERATED_MOCK_FILE_REGEX="^// Code generated by mockery v[0-9.]\+. DO NOT EDIT.$"
# pick a tempfile path for writing to
tmp=$(mktemp)
@@ -52,7 +52,7 @@ git_grep -l -z "${GENERATED_MOCK_FILE_REGEX}" | xargs -0 rm -f
echo 'executing go generate command on below files'
git_grep -l -z "//go:generate mockgen" | while read -r -d $'\0' file; do
git_grep -l -z "//go:generate mockery" | while read -r -d $'\0' file; do
echo "- ${file}"
temp_file_name="$(kube::realpath "$(mktemp -t "$(basename "$0").XXXXXX")")"