Repository: kubernetes-sigs/kueue

Issue:
Introduce a library for mocking in unit tests and consolidate current mocks
<!-- Please only use this template for submitting clean up requests -->

**What would you like to be cleaned**:

Use a library, like uber-go/mock to consolidate the mocking for GenericJob:
- testGenericJob in validation_test.go and (almost identical copy) in base_webhook_test.go

This was first proposed in https://github.com/kubernetes-sigs/kueue/pull/5510#discussion_r2183633446 

**Why is this needed**:

To simplify the test code, and avoid duplication for writing mocks per-test.

Discussion:
@mimowo: cc @tenzen-y @ichekrygin @tenzen-y: Is it only for Unit Test, right?
@mimowo: Yes, updated title@tenzen-y: In terms of uber-go/mock vs testify, +1 on uber-go/mock since it is originally came from Go std library.@mbobrovskyi: /assign@ichekrygin: Hi @mbobrovskyi, while working on an unrelated PR I came across a need to use a mock for the GenericJob interface.
I’m not sure if you’ve made progress on this issue yet, but if not, I have a PR almost ready that adds this functionality, so I was wondering if you would be open to me taking over this issue in that case?
@ichekrygin: > Hi [@mbobrovskyi](https://github.com/mbobrovskyi), while working on an unrelated PR I came across a need to use a mock for the GenericJob interface.
> I’m not sure if you’ve made progress on this issue yet, but if not, I have a PR almost ready that adds this functionality, so I was wondering if you would be open to me taking over this issue in that case?

Please disregard. I had "outdated" view on the issue, and entirely missed your PR. I just closed mine.

Solution patch:
diff --git a/Makefile b/Makefile
index f94852f1f..256a04203 100644
--- a/Makefile
+++ b/Makefile
@@ -52,6 +52,7 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
 BIN_DIR ?= $(PROJECT_DIR)/bin
 ARTIFACTS ?= $(BIN_DIR)
 TOOLS_DIR := $(PROJECT_DIR)/hack/internal/tools
+MOCKS_DIR := internal/mocks
 
 # Use distroless as minimal base image to package the manager binary
 # Refer to https://github.com/GoogleContainerTools/distroless for more details
@@ -132,13 +133,19 @@ update-helm: manifests yq yaml-processor
 	$(BIN_DIR)/yaml-processor -zap-log-level=$(YAML_PROCESSOR_LOG_LEVEL) hack/processing-plan.yaml
 
 .PHONY: generate
-generate: gomod-download generate-apiref generate-code generate-kueuectl-docs generate-helm-docs
+generate: gomod-download generate-mocks generate-apiref generate-code generate-kueuectl-docs generate-helm-docs
 
 .PHONY: generate-code
 generate-code: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations and client-go libraries.
 	$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/..."
 	TOOLS_DIR=${TOOLS_DIR} ./hack/update-codegen.sh $(GO_CMD)
 
+.PHONY: generate-mocks
+generate-mocks: mockgen ## Generate mockgen mocks
+	# Clean up previously generated mocks to keep generated mocks up-to-date.
+	rm -rf $(MOCKS_DIR)
+	$(MOCKGEN) -destination=$(MOCKS_DIR)/controller/jobframework/interface.go -package mocks sigs.k8s.io/kueue/pkg/controller/jobframework GenericJob,JobWithCustomValidation,JobWithManagedBy
+
 .PHONY: fmt
 fmt: ## Run go fmt against code.
 	$(GO_CMD) fmt ./...
diff --git a/Makefile-deps.mk b/Makefile-deps.mk
index fd411d668..94bf9fc8e 100644
--- a/Makefile-deps.mk
+++ b/Makefile-deps.mk
@@ -28,6 +28,7 @@ GENREF_VERSION = $(shell cd $(TOOLS_DIR); $(GO_CMD) list -m -f '{{.Version}}' gi
 HUGO_VERSION ?= $(shell cd $(TOOLS_DIR); $(GO_CMD) list -m -f '{{.Version}}' github.com/gohugoio/hugo)
 MDTOC_VERSION ?= $(shell cd $(TOOLS_DIR); $(GO_CMD) list -m -f '{{.Version}}' sigs.k8s.io/mdtoc)
 HELM_DOCS_VERSION ?= $(shell cd $(TOOLS_DIR); $(GO_CMD) list -m -f '{{.Version}}' github.com/norwoodj/helm-docs)
+MOCKGEN_VERSION ?= $(shell cd $(TOOLS_DIR); $(GO_CMD) list -m -f '{{.Version}}' go.uber.org/mock)
 
 # Versions for external controllers
 JOBSET_VERSION = $(shell $(GO_CMD) list -m -f "{{.Version}}" sigs.k8s.io/jobset)
@@ -51,6 +52,7 @@ GENREF = $(BIN_DIR)/genref
 HUGO = $(BIN_DIR)/hugo
 MDTOC = $(BIN_DIR)/mdtoc
 HELM_DOCS = $(BIN_DIR)/helm-docs
+MOCKGEN = $(BIN_DIR)/mockgen
 
 MPI_ROOT = $(shell $(GO_CMD) list -m -mod=readonly -f "{{.Dir}}" github.com/kubeflow/mpi-operator)
 KF_TRAINING_ROOT = $(shell $(GO_CMD) list -m -mod=readonly -f "{{.Dir}}" github.com/kubeflow/training-operator)
@@ -117,6 +119,10 @@ mdtoc: ## Download mdtoc locally if necessary.
 helm-docs: ## Download helm-docs locally if necessary.
 	@GOBIN=$(BIN_DIR) CGO_ENABLED=1 $(GO_CMD) install github.com/norwoodj/helm-docs/cmd/helm-docs@$(HELM_DOCS_VERSION)
 
+.PHONY: mockgen
+mockgen: ## Download mockgen locally if necessary.
+	@GOBIN=$(BIN_DIR) CGO_ENABLED=1 $(GO_CMD) install go.uber.org/mock/mockgen@$(MOCKGEN_VERSION)
+
 ##@ External CRDs
 
 .PHONY: mpi-operator-crd
diff --git a/go.mod b/go.mod
index 63855b023..19f1168df 100644
--- a/go.mod
+++ b/go.mod
@@ -19,6 +19,7 @@ require (
 	github.com/ray-project/kuberay/ray-operator v1.4.2
 	github.com/spf13/cobra v1.9.1
 	github.com/spf13/pflag v1.0.7
+	go.uber.org/mock v0.6.0
 	go.uber.org/zap v1.27.0
 	golang.org/x/exp v0.0.0-20250305212735-054e65f0b394
 	golang.org/x/sync v0.16.0
diff --git a/go.sum b/go.sum
index 58cc27e3f..03ecc0194 100644
--- a/go.sum
+++ b/go.sum
@@ -268,6 +268,8 @@ go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
 go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
 go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
 go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
+go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
+go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
 go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
 go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
 go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
diff --git a/hack/internal/tools/go.mod b/hack/internal/tools/go.mod
index 30c759605..b9bfbb5d1 100644
--- a/hack/internal/tools/go.mod
+++ b/hack/internal/tools/go.mod
@@ -9,6 +9,7 @@ tool (
 	github.com/mikefarah/yq/v4
 	github.com/norwoodj/helm-docs/cmd/helm-docs
 	github.com/onsi/ginkgo/v2/ginkgo
+	go.uber.org/mock/mockgen
 	gotest.tools/gotestsum
 	helm.sh/helm/v3/cmd/helm
 	k8s.io/code-generator
@@ -427,6 +428,7 @@ require (
 	go.opentelemetry.io/otel/sdk/metric v1.36.0 // indirect
 	go.opentelemetry.io/otel/trace v1.36.0 // indirect
 	go.uber.org/automaxprocs v1.6.0 // indirect
+	go.uber.org/mock v0.6.0 // indirect
 	go.uber.org/multierr v1.11.0 // indirect
 	go.yaml.in/yaml/v2 v2.4.2 // indirect
 	go.yaml.in/yaml/v3 v3.0.4 // indirect
diff --git a/hack/internal/tools/go.sum b/hack/internal/tools/go.sum
index 8da8abc95..004c07eaf 100644
--- a/hack/internal/tools/go.sum
+++ b/hack/internal/tools/go.sum
@@ -1179,6 +1179,8 @@ go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
 go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
 go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
 go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
+go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
+go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
 go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
 go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
 go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
diff --git a/internal/mocks/controller/jobframework/interface.go b/internal/mocks/controller/jobframework/interface.go
new file mode 100644
index 000000000..ec0ca319b
--- /dev/null
+++ b/internal/mocks/controller/jobframework/interface.go
@@ -0,0 +1,305 @@
+// Code generated by MockGen. DO NOT EDIT.
+// Source: sigs.k8s.io/kueue/pkg/controller/jobframework (interfaces: GenericJob,JobWithCustomValidation,JobWithManagedBy)
+//
+// Generated by this command:
+//
+//	mockgen -destination=internal/mocks/controller/jobframework/interface.go -package mocks sigs.k8s.io/kueue/pkg/controller/jobframework GenericJob,JobWithCustomValidation,JobWithManagedBy
+//
+
+// Package mocks is a generated GoMock package.
+package mocks
+
+import (
+	reflect "reflect"
+
+	gomock "go.uber.org/mock/gomock"
+	schema "k8s.io/apimachinery/pkg/runtime/schema"
+	field "k8s.io/apimachinery/pkg/util/validation/field"
+	client "sigs.k8s.io/controller-runtime/pkg/client"
+	v1beta1 "sigs.k8s.io/kueue/apis/kueue/v1beta1"
+	jobframework "sigs.k8s.io/kueue/pkg/controller/jobframework"
+	podset "sigs.k8s.io/kueue/pkg/podset"
+)
+
+// MockGenericJob is a mock of GenericJob interface.
+type MockGenericJob struct {
+	ctrl     *gomock.Controller
+	recorder *MockGenericJobMockRecorder
+	isgomock struct{}
+}
+
+// MockGenericJobMockRecorder is the mock recorder for MockGenericJob.
+type MockGenericJobMockRecorder struct {
+	mock *MockGenericJob
+}
+
+// NewMockGenericJob creates a new mock instance.
+func NewMockGenericJob(ctrl *gomock.Controller) *MockGenericJob {
+	mock := &MockGenericJob{ctrl: ctrl}
+	mock.recorder = &MockGenericJobMockRecorder{mock}
+	return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockGenericJob) EXPECT() *MockGenericJobMockRecorder {
+	return m.recorder
+}
+
+// Finished mocks base method.
+func (m *MockGenericJob) Finished() (string, bool, bool) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "Finished")
+	ret0, _ := ret[0].(string)
+	ret1, _ := ret[1].(bool)
+	ret2, _ := ret[2].(bool)
+	return ret0, ret1, ret2
+}
+
+// Finished indicates an expected call of Finished.
+func (mr *MockGenericJobMockRecorder) Finished() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Finished", reflect.TypeOf((*MockGenericJob)(nil).Finished))
+}
+
+// GVK mocks base method.
+func (m *MockGenericJob) GVK() schema.GroupVersionKind {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "GVK")
+	ret0, _ := ret[0].(schema.GroupVersionKind)
+	return ret0
+}
+
+// GVK indicates an expected call of GVK.
+func (mr *MockGenericJobMockRecorder) GVK() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GVK", reflect.TypeOf((*MockGenericJob)(nil).GVK))
+}
+
+// IsActive mocks base method.
+func (m *MockGenericJob) IsActive() bool {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "IsActive")
+	ret0, _ := ret[0].(bool)
+	return ret0
+}
+
+// IsActive indicates an expected call of IsActive.
+func (mr *MockGenericJobMockRecorder) IsActive() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsActive", reflect.TypeOf((*MockGenericJob)(nil).IsActive))
+}
+
+// IsSuspended mocks base method.
+func (m *MockGenericJob) IsSuspended() bool {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "IsSuspended")
+	ret0, _ := ret[0].(bool)
+	return ret0
+}
+
+// IsSuspended indicates an expected call of IsSuspended.
+func (mr *MockGenericJobMockRecorder) IsSuspended() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSuspended", reflect.TypeOf((*MockGenericJob)(nil).IsSuspended))
+}
+
+// Object mocks base method.
+func (m *MockGenericJob) Object() client.Object {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "Object")
+	ret0, _ := ret[0].(client.Object)
+	return ret0
+}
+
+// Object indicates an expected call of Object.
+func (mr *MockGenericJobMockRecorder) Object() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Object", reflect.TypeOf((*MockGenericJob)(nil).Object))
+}
+
+// PodSets mocks base method.
+func (m *MockGenericJob) PodSets() ([]v1beta1.PodSet, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "PodSets")
+	ret0, _ := ret[0].([]v1beta1.PodSet)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// PodSets indicates an expected call of PodSets.
+func (mr *MockGenericJobMockRecorder) PodSets() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PodSets", reflect.TypeOf((*MockGenericJob)(nil).PodSets))
+}
+
+// PodsReady mocks base method.
+func (m *MockGenericJob) PodsReady() bool {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "PodsReady")
+	ret0, _ := ret[0].(bool)
+	return ret0
+}
+
+// PodsReady indicates an expected call of PodsReady.
+func (mr *MockGenericJobMockRecorder) PodsReady() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PodsReady", reflect.TypeOf((*MockGenericJob)(nil).PodsReady))
+}
+
+// RestorePodSetsInfo mocks base method.
+func (m *MockGenericJob) RestorePodSetsInfo(podSetsInfo []podset.PodSetInfo) bool {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "RestorePodSetsInfo", podSetsInfo)
+	ret0, _ := ret[0].(bool)
+	return ret0
+}
+
+// RestorePodSetsInfo indicates an expected call of RestorePodSetsInfo.
+func (mr *MockGenericJobMockRecorder) RestorePodSetsInfo(podSetsInfo any) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RestorePodSetsInfo", reflect.TypeOf((*MockGenericJob)(nil).RestorePodSetsInfo), podSetsInfo)
+}
+
+// RunWithPodSetsInfo mocks base method.
+func (m *MockGenericJob) RunWithPodSetsInfo(podSetsInfo []podset.PodSetInfo) error {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "RunWithPodSetsInfo", podSetsInfo)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+// RunWithPodSetsInfo indicates an expected call of RunWithPodSetsInfo.
+func (mr *MockGenericJobMockRecorder) RunWithPodSetsInfo(podSetsInfo any) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunWithPodSetsInfo", reflect.TypeOf((*MockGenericJob)(nil).RunWithPodSetsInfo), podSetsInfo)
+}
+
+// Suspend mocks base method.
+func (m *MockGenericJob) Suspend() {
+	m.ctrl.T.Helper()
+	m.ctrl.Call(m, "Suspend")
+}
+
+// Suspend indicates an expected call of Suspend.
+func (mr *MockGenericJobMockRecorder) Suspend() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Suspend", reflect.TypeOf((*MockGenericJob)(nil).Suspend))
+}
+
+// MockJobWithCustomValidation is a mock of JobWithCustomValidation interface.
+type MockJobWithCustomValidation struct {
+	ctrl     *gomock.Controller
+	recorder *MockJobWithCustomValidationMockRecorder
+	isgomock struct{}
+}
+
+// MockJobWithCustomValidationMockRecorder is the mock recorder for MockJobWithCustomValidation.
+type MockJobWithCustomValidationMockRecorder struct {
+	mock *MockJobWithCustomValidation
+}
+
+// NewMockJobWithCustomValidation creates a new mock instance.
+func NewMockJobWithCustomValidation(ctrl *gomock.Controller) *MockJobWithCustomValidation {
+	mock := &MockJobWithCustomValidation{ctrl: ctrl}
+	mock.recorder = &MockJobWithCustomValidationMockRecorder{mock}
+	return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockJobWithCustomValidation) EXPECT() *MockJobWithCustomValidationMockRecorder {
+	return m.recorder
+}
+
+// ValidateOnCreate mocks base method.
+func (m *MockJobWithCustomValidation) ValidateOnCreate() (field.ErrorList, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ValidateOnCreate")
+	ret0, _ := ret[0].(field.ErrorList)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// ValidateOnCreate indicates an expected call of ValidateOnCreate.
+func (mr *MockJobWithCustomValidationMockRecorder) ValidateOnCreate() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateOnCreate", reflect.TypeOf((*MockJobWithCustomValidation)(nil).ValidateOnCreate))
+}
+
+// ValidateOnUpdate mocks base method.
+func (m *MockJobWithCustomValidation) ValidateOnUpdate(oldJob jobframework.GenericJob) (field.ErrorList, error) {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ValidateOnUpdate", oldJob)
+	ret0, _ := ret[0].(field.ErrorList)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+// ValidateOnUpdate indicates an expected call of ValidateOnUpdate.
+func (mr *MockJobWithCustomValidationMockRecorder) ValidateOnUpdate(oldJob any) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidateOnUpdate", reflect.TypeOf((*MockJobWithCustomValidation)(nil).ValidateOnUpdate), oldJob)
+}
+
+// MockJobWithManagedBy is a mock of JobWithManagedBy interface.
+type MockJobWithManagedBy struct {
+	ctrl     *gomock.Controller
+	recorder *MockJobWithManagedByMockRecorder
+	isgomock struct{}
+}
+
+// MockJobWithManagedByMockRecorder is the mock recorder for MockJobWithManagedBy.
+type MockJobWithManagedByMockRecorder struct {
+	mock *MockJobWithManagedBy
+}
+
+// NewMockJobWithManagedBy creates a new mock instance.
+func NewMockJobWithManagedBy(ctrl *gomock.Controller) *MockJobWithManagedBy {
+	mock := &MockJobWithManagedBy{ctrl: ctrl}
+	mock.recorder = &MockJobWithManagedByMockRecorder{mock}
+	return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *MockJobWithManagedBy) EXPECT() *MockJobWithManagedByMockRecorder {
+	return m.recorder
+}
+
+// CanDefaultManagedBy mocks base method.
+func (m *MockJobWithManagedBy) CanDefaultManagedBy() bool {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "CanDefaultManagedBy")
+	ret0, _ := ret[0].(bool)
+	return ret0
+}
+
+// CanDefaultManagedBy indicates an expected call of CanDefaultManagedBy.
+func (mr *MockJobWithManagedByMockRecorder) CanDefaultManagedBy() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CanDefaultManagedBy", reflect.TypeOf((*MockJobWithManagedBy)(nil).CanDefaultManagedBy))
+}
+
+// ManagedBy mocks base method.
+func (m *MockJobWithManagedBy) ManagedBy() *string {
+	m.ctrl.T.Helper()
+	ret := m.ctrl.Call(m, "ManagedBy")
+	ret0, _ := ret[0].(*string)
+	return ret0
+}
+
+// ManagedBy indicates an expected call of ManagedBy.
+func (mr *MockJobWithManagedByMockRecorder) ManagedBy() *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ManagedBy", reflect.TypeOf((*MockJobWithManagedBy)(nil).ManagedBy))
+}
+
+// SetManagedBy mocks base method.
+func (m *MockJobWithManagedBy) SetManagedBy(arg0 *string) {
+	m.ctrl.T.Helper()
+	m.ctrl.Call(m, "SetManagedBy", arg0)
+}
+
+// SetManagedBy indicates an expected call of SetManagedBy.
+func (mr *MockJobWithManagedByMockRecorder) SetManagedBy(arg0 any) *gomock.Call {
+	mr.mock.ctrl.T.Helper()
+	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetManagedBy", reflect.TypeOf((*MockJobWithManagedBy)(nil).SetManagedBy), arg0)
+}
diff --git a/vendor/go.uber.org/mock/AUTHORS b/vendor/go.uber.org/mock/AUTHORS
new file mode 100644
index 000000000..660b8ccc8
--- /dev/null
+++ b/vendor/go.uber.org/mock/AUTHORS
@@ -0,0 +1,12 @@
+# This is the official list of GoMock authors for copyright purposes.
+# This file is distinct from the CONTRIBUTORS files.
+# See the latter for an explanation.
+
+# Names should be added to this file as
+#	Name or Organization <email address>
+# The email address is not required for organizations.
+
+# Please keep the list sorted.
+
+Alex Reece <awreece@gmail.com>
+Google Inc.
diff --git a/vendor/go.uber.org/mock/LICENSE b/vendor/go.uber.org/mock/LICENSE
new file mode 100644
index 000000000..d64569567
--- /dev/null
+++ b/vendor/go.uber.org/mock/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/vendor/go.uber.org/mock/gomock/call.go b/vendor/go.uber.org/mock/gomock/call.go
new file mode 100644
index 000000000..e1fe222af
--- /dev/null
+++ b/vendor/go.uber.org/mock/gomock/call.go
@@ -0,0 +1,506 @@
+// Copyright 2010 Google Inc.
+//
+// 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.
+
+package gomock
+
+import (
+	"fmt"
+	"reflect"
+	"strconv"
+	"strings"
+)
+
+// Call represents an expected call to a mock.
+type Call struct {
+	t TestHelper // for triggering test failures on invalid call setup
+
+	receiver   any          // the receiver of the method call
+	method     string       // the name of the method
+	methodType reflect.Type // the type of the method
+	args       []Matcher    // the args
+	origin     string       // file and line number of call setup
+
+	preReqs []*Call // prerequisite calls
+
+	// Expectations
+	minCalls, maxCalls int
+
+	numCalls int // actual number made
+
+	// actions are called when this Call is called. Each action gets the args and
+	// can set the return values by returning a non-nil slice. Actions run in the
+	// order they are created.
+	actions []func([]any) []any
+}
+
+// newCall creates a *Call. It requires the method type in order to support
+// unexported methods.
+func newCall(t TestHelper, receiver any, method string, methodType reflect.Type, args ...any) *Call {
+	t.Helper()
+
+	// TODO: check arity, types.
+	mArgs := make([]Matcher, len(args))
+	for i, arg := range args {
+		if m, ok := arg.(Matcher); ok {
+			mArgs[i] = m
+		} else if arg == nil {
+			// Handle nil specially so that passing a nil interface value
+			// will match the typed nils of concrete args.
+			mArgs[i] = Nil()
+		} else {
+			mArgs[i] = Eq(arg)
+		}
+	}
+
+	// callerInfo's skip should be updated if the number of calls between the user's test
+	// and this line changes, i.e. this code is wrapped in another anonymous function.
+	// 0 is us, 1 is RecordCallWithMethodType(), 2 is the generated recorder, and 3 is the user's test.
+	origin := callerInfo(3)
+	actions := []func([]any) []any{func([]any) []any {
+		// Synthesize the zero value for each of the return args' types.
+		rets := make([]any, methodType.NumOut())
+		for i := 0; i < methodType.NumOut(); i++ {
+			rets[i] = reflect.Zero(methodType.Out(i)).Interface()
+		}
+		return rets
+	}}
+	return &Call{
+		t: t, receiver: receiver, method: method, methodType: methodType,
+		args: mArgs, origin: origin, minCalls: 1, maxCalls: 1, actions: actions,
+	}
+}
+
+// AnyTimes allows the expectation to be called 0 or more times
+func (c *Call) AnyTimes() *Call {
+	c.minCalls, c.maxCalls = 0, 1e8 // close enough to infinity
+	return c
+}
+
+// MinTimes requires the call to occur at least n times. If AnyTimes or MaxTimes have not been called or if MaxTimes
+// was previously called with 1, MinTimes also sets the maximum number of calls to infinity.
+func (c *Call) MinTimes(n int) *Call {
+	c.minCalls = n
+	if c.maxCalls == 1 {
+		c.maxCalls = 1e8
+	}
+	return c
+}
+
+// MaxTimes limits the number of calls to n times. If AnyTimes or MinTimes have not been called or if MinTimes was
+// previously called with 1, MaxTimes also sets the minimum number of calls to 0.
+func (c *Call) MaxTimes(n int) *Call {
+	c.maxCalls = n
+	if c.minCalls == 1 {
+		c.minCalls = 0
+	}
+	return c
+}
+
+// DoAndReturn declares the action to run when the call is matched.
+// The return values from this function are returned by the mocked function.
+// It takes an any argument to support n-arity functions.
+// The anonymous function must match the function signature mocked method.
+func (c *Call) DoAndReturn(f any) *Call {
+	// TODO: Check arity and types here, rather than dying badly elsewhere.
+	v := reflect.ValueOf(f)
+
+	c.addAction(func(args []any) []any {
+		c.t.Helper()
+		ft := v.Type()
+		if c.methodType.NumIn() != ft.NumIn() {
+			if ft.IsVariadic() {
+				c.t.Fatalf("wrong number of arguments in DoAndReturn func for %T.%v The function signature must match the mocked method, a variadic function cannot be used.",
+					c.receiver, c.method)
+			} else {
+				c.t.Fatalf("wrong number of arguments in DoAndReturn func for %T.%v: got %d, want %d [%s]",
+					c.receiver, c.method, ft.NumIn(), c.methodType.NumIn(), c.origin)
+			}
+			return nil
+		}
+		vArgs := make([]reflect.Value, len(args))
+		for i := 0; i < len(args); i++ {
+			if args[i] != nil {
+				vArgs[i] = reflect.ValueOf(args[i])
+			} else {
+				// Use the zero value for the arg.
+				vArgs[i] = reflect.Zero(ft.In(i))
+			}
+		}
+		vRets := v.Call(vArgs)
+		rets := make([]any, len(vRets))
+		for i, ret := range vRets {
+			rets[i] = ret.Interface()
+		}
+		return rets
+	})
+	return c
+}
+
+// Do declares the action to run when the call is matched. The function's
+// return values are ignored to retain backward compatibility. To use the
+// return values call DoAndReturn.
+// It takes an any argument to support n-arity functions.
+// The anonymous function must match the function signature mocked method.
+func (c *Call) Do(f any) *Call {
+	// TODO: Check arity and types here, rather than dying badly elsewhere.
+	v := reflect.ValueOf(f)
+
+	c.addAction(func(args []any) []any {
+		c.t.Helper()
+		ft := v.Type()
+		if c.methodType.NumIn() != ft.NumIn() {
+			if ft.IsVariadic() {
+				c.t.Fatalf("wrong number of arguments in Do func for %T.%v The function signature must match the mocked method, a variadic function cannot be used.",
+					c.receiver, c.method)
+			} else {
+				c.t.Fatalf("wrong number of arguments in Do func for %T.%v: got %d, want %d [%s]",
+					c.receiver, c.method, ft.NumIn(), c.methodType.NumIn(), c.origin)
+			}
+			return nil
+		}
+		vArgs := make([]reflect.Value, len(args))
+		for i := 0; i < len(args); i++ {
+			if args[i] != nil {
+				vArgs[i] = reflect.ValueOf(args[i])
+			} else {
+				// Use the zero value for the arg.
+				vArgs[i] = reflect.Zero(ft.In(i))
+			}
+		}
+		v.Call(vArgs)
+		return nil
+	})
+	return c
+}
+
+// Return declares the values to be returned by the mocked function call.
+func (c *Call) Return(rets ...any) *Call {
+	c.t.Helper()
+
+	mt := c.methodType
+	if len(rets) != mt.NumOut() {
+		c.t.Fatalf("wrong number of arguments to Return for %T.%v: got %d, want %d [%s]",
+			c.receiver, c.method, len(rets), mt.NumOut(), c.origin)
+	}
+	for i, ret := range rets {
+		if got, want := reflect.TypeOf(ret), mt.Out(i); got == want {
+			// Identical types; nothing to do.
+		} else if got == nil {
+			// Nil needs special handling.
+			switch want.Kind() {
+			case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
+				// ok
+			default:
+				c.t.Fatalf("argument %d to Return for %T.%v is nil, but %v is not nillable [%s]",
+					i, c.receiver, c.method, want, c.origin)
+			}
+		} else if got.AssignableTo(want) {
+			// Assignable type relation. Make the assignment now so that the generated code
+			// can return the values with a type assertion.
+			v := reflect.New(want).Elem()
+			v.Set(reflect.ValueOf(ret))
+			rets[i] = v.Interface()
+		} else {
+			c.t.Fatalf("wrong type of argument %d to Return for %T.%v: %v is not assignable to %v [%s]",
+				i, c.receiver, c.method, got, want, c.origin)
+		}
+	}
+
+	c.addAction(func([]any) []any {
+		return rets
+	})
+
+	return c
+}
+
+// Times declares the exact number of times a function call is expected to be executed.
+func (c *Call) Times(n int) *Call {
+	c.minCalls, c.maxCalls = n, n
+	return c
+}
+
+// SetArg declares an action that will set the nth argument's value,
+// indirected through a pointer. Or, in the case of a slice and map, SetArg
+// will copy value's elements/key-value pairs into the nth argument.
+func (c *Call) SetArg(n int, value any) *Call {
+	c.t.Helper()
+
+	mt := c.methodType
+	// TODO: This will break on variadic methods.
+	// We will need to check those at invocation time.
+	if n < 0 || n >= mt.NumIn() {
+		c.t.Fatalf("SetArg(%d, ...) called for a method with %d args [%s]",
+			n, mt.NumIn(), c.origin)
+	}
+	// Permit setting argument through an interface.
+	// In the interface case, we don't (nay, can't) check the type here.
+	at := mt.In(n)
+	switch at.Kind() {
+	case reflect.Ptr:
+		dt := at.Elem()
+		if vt := reflect.TypeOf(value); !vt.AssignableTo(dt) {
+			c.t.Fatalf("SetArg(%d, ...) argument is a %v, not assignable to %v [%s]",
+				n, vt, dt, c.origin)
+		}
+	case reflect.Interface, reflect.Slice, reflect.Map:
+		// nothing to do
+	default:
+		c.t.Fatalf("SetArg(%d, ...) referring to argument of non-pointer non-interface non-slice non-map type %v [%s]",
+			n, at, c.origin)
+	}
+
+	c.addAction(func(args []any) []any {
+		v := reflect.ValueOf(value)
+		switch reflect.TypeOf(args[n]).Kind() {
+		case reflect.Slice:
+			setSlice(args[n], v)
+		case reflect.Map:
+			setMap(args[n], v)
+		default:
+			reflect.ValueOf(args[n]).Elem().Set(v)
+		}
+		return nil
+	})
+	return c
+}
+
+// isPreReq returns true if other is a direct or indirect prerequisite to c.
+func (c *Call) isPreReq(other *Call) bool {
+	for _, preReq := range c.preReqs {
+		if other == preReq || preReq.isPreReq(other) {
+			return true
+		}
+	}
+	return false
+}
+
+// After declares that the call may only match after preReq has been exhausted.
+func (c *Call) After(preReq *Call) *Call {
+	c.t.Helper()
+
+	if c == preReq {
+		c.t.Fatalf("A call isn't allowed to be its own prerequisite")
+	}
+	if preReq.isPreReq(c) {
+		c.t.Fatalf("Loop in call order: %v is a prerequisite to %v (possibly indirectly).", c, preReq)
+	}
+
+	c.preReqs = append(c.preReqs, preReq)
+	return c
+}
+
+// Returns true if the minimum number of calls have been made.
+func (c *Call) satisfied() bool {
+	return c.numCalls >= c.minCalls
+}
+
+// Returns true if the maximum number of calls have been made.
+func (c *Call) exhausted() bool {
+	return c.numCalls >= c.maxCalls
+}
+
+func (c *Call) String() string {
+	args := make([]string, len(c.args))
+	for i, arg := range c.args {
+		args[i] = arg.String()
+	}
+	arguments := strings.Join(args, ", ")
+	return fmt.Sprintf("%T.%v(%s) %s", c.receiver, c.method, arguments, c.origin)
+}
+
+// Tests if the given call matches the expected call.
+// If yes, returns nil. If no, returns error with message explaining why it does not match.
+func (c *Call) matches(args []any) error {
+	if !c.methodType.IsVariadic() {
+		if len(args) != len(c.args) {
+			return fmt.Errorf("expected call at %s has the wrong number of arguments. Got: %d, want: %d",
+				c.origin, len(args), len(c.args))
+		}
+
+		for i, m := range c.args {
+			if !m.Matches(args[i]) {
+				return fmt.Errorf(
+					"expected call at %s doesn't match the argument at index %d.\nGot: %v\nWant: %v",
+					c.origin, i, formatGottenArg(m, args[i]), m,
+				)
+			}
+		}
+	} else {
+		if len(c.args) < c.methodType.NumIn()-1 {
+			return fmt.Errorf("expected call at %s has the wrong number of matchers. Got: %d, want: %d",
+				c.origin, len(c.args), c.methodType.NumIn()-1)
+		}
+		if len(c.args) != c.methodType.NumIn() && len(args) != len(c.args) {
+			return fmt.Errorf("expected call at %s has the wrong number of arguments. Got: %d, want: %d",
+				c.origin, len(args), len(c.args))
+		}
+		if len(args) < len(c.args)-1 {
+			return fmt.Errorf("expected call at %s has the wrong number of arguments. Got: %d, want: greater than or equal to %d",
+				c.origin, len(args), len(c.args)-1)
+		}
+
+		for i, m := range c.args {
+			if i < c.methodType.NumIn()-1 {
+				// Non-variadic args
+				if !m.Matches(args[i]) {
+					return fmt.Errorf("expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v",
+						c.origin, strconv.Itoa(i), formatGottenArg(m, args[i]), m)
+				}
+				continue
+			}
+			// The last arg has a possibility of a variadic argument, so let it branch
+
+			// sample: Foo(a int, b int, c ...int)
+			if i < len(c.args) && i < len(args) {
+				if m.Matches(args[i]) {
+					// Got Foo(a, b, c) want Foo(matcherA, matcherB, gomock.Any())
+					// Got Foo(a, b, c) want Foo(matcherA, matcherB, someSliceMatcher)
+					// Got Foo(a, b, c) want Foo(matcherA, matcherB, matcherC)
+					// Got Foo(a, b) want Foo(matcherA, matcherB)
+					// Got Foo(a, b, c, d) want Foo(matcherA, matcherB, matcherC, matcherD)
+					continue
+				}
+			}
+
+			// The number of actual args don't match the number of matchers,
+			// or the last matcher is a slice and the last arg is not.
+			// If this function still matches it is because the last matcher
+			// matches all the remaining arguments or the lack of any.
+			// Convert the remaining arguments, if any, into a slice of the
+			// expected type.
+			vArgsType := c.methodType.In(c.methodType.NumIn() - 1)
+			vArgs := reflect.MakeSlice(vArgsType, 0, len(args)-i)
+			for _, arg := range args[i:] {
+				vArgs = reflect.Append(vArgs, reflect.ValueOf(arg))
+			}
+			if m.Matches(vArgs.Interface()) {
+				// Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, gomock.Any())
+				// Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, someSliceMatcher)
+				// Got Foo(a, b) want Foo(matcherA, matcherB, gomock.Any())
+				// Got Foo(a, b) want Foo(matcherA, matcherB, someEmptySliceMatcher)
+				break
+			}
+			// Wrong number of matchers or not match. Fail.
+			// Got Foo(a, b) want Foo(matcherA, matcherB, matcherC, matcherD)
+			// Got Foo(a, b, c) want Foo(matcherA, matcherB, matcherC, matcherD)
+			// Got Foo(a, b, c, d) want Foo(matcherA, matcherB, matcherC, matcherD, matcherE)
+			// Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, matcherC, matcherD)
+			// Got Foo(a, b, c) want Foo(matcherA, matcherB)
+
+			return fmt.Errorf("expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v",
+				c.origin, strconv.Itoa(i), formatGottenArg(m, args[i:]), c.args[i])
+		}
+	}
+
+	// Check that all prerequisite calls have been satisfied.
+	for _, preReqCall := range c.preReqs {
+		if !preReqCall.satisfied() {
+			return fmt.Errorf("expected call at %s doesn't have a prerequisite call satisfied:\n%v\nshould be called before:\n%v",
+				c.origin, preReqCall, c)
+		}
+	}
+
+	// Check that the call is not exhausted.
+	if c.exhausted() {
+		return fmt.Errorf("expected call at %s has already been called the max number of times", c.origin)
+	}
+
+	return nil
+}
+
+// dropPrereqs tells the expected Call to not re-check prerequisite calls any
+// longer, and to return its current set.
+func (c *Call) dropPrereqs() (preReqs []*Call) {
+	preReqs = c.preReqs
+	c.preReqs = nil
+	return
+}
+
+func (c *Call) call() []func([]any) []any {
+	c.numCalls++
+	return c.actions
+}
+
+// InOrder declares that the given calls should occur in order.
+// It panics if the type of any of the arguments isn't *Call or a generated
+// mock with an embedded *Call.
+func InOrder(args ...any) {
+	calls := make([]*Call, 0, len(args))
+	for i := 0; i < len(args); i++ {
+		if call := getCall(args[i]); call != nil {
+			calls = append(calls, call)
+			continue
+		}
+		panic(fmt.Sprintf(
+			"invalid argument at position %d of type %T, InOrder expects *gomock.Call or generated mock types with an embedded *gomock.Call",
+			i,
+			args[i],
+		))
+	}
+	for i := 1; i < len(calls); i++ {
+		calls[i].After(calls[i-1])
+	}
+}
+
+// getCall checks if the parameter is a *Call or a generated struct
+// that wraps a *Call and returns the *Call pointer - if neither, it returns nil.
+func getCall(arg any) *Call {
+	if call, ok := arg.(*Call); ok {
+		return call
+	}
+	t := reflect.ValueOf(arg)
+	if t.Kind() != reflect.Ptr && t.Kind() != reflect.Interface {
+		return nil
+	}
+	t = t.Elem()
+	for i := 0; i < t.NumField(); i++ {
+		f := t.Field(i)
+		if !f.CanInterface() {
+			continue
+		}
+		if call, ok := f.Interface().(*Call); ok {
+			return call
+		}
+	}
+	return nil
+}
+
+func setSlice(arg any, v reflect.Value) {
+	va := reflect.ValueOf(arg)
+	for i := 0; i < v.Len(); i++ {
+		va.Index(i).Set(v.Index(i))
+	}
+}
+
+func setMap(arg any, v reflect.Value) {
+	va := reflect.ValueOf(arg)
+	for _, e := range va.MapKeys() {
+		va.SetMapIndex(e, reflect.Value{})
+	}
+	for _, e := range v.MapKeys() {
+		va.SetMapIndex(e, v.MapIndex(e))
+	}
+}
+
+func (c *Call) addAction(action func([]any) []any) {
+	c.actions = append(c.actions, action)
+}
+
+func formatGottenArg(m Matcher, arg any) string {
+	got := fmt.Sprintf("%v (%T)", arg, arg)
+	if gs, ok := m.(GotFormatter); ok {
+		got = gs.Got(arg)
+	}
+	return got
+}
diff --git a/vendor/go.uber.org/mock/gomock/callset.go b/vendor/go.uber.org/mock/gomock/callset.go
new file mode 100644
index 000000000..f5cc592d6
--- /dev/null
+++ b/vendor/go.uber.org/mock/gomock/callset.go
@@ -0,0 +1,164 @@
+// Copyright 2011 Google Inc.
+//
+// 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.
+
+package gomock
+
+import (
+	"bytes"
+	"errors"
+	"fmt"
+	"sync"
+)
+
+// callSet represents a set of expected calls, indexed by receiver and method
+// name.
+type callSet struct {
+	// Calls that are still expected.
+	expected   map[callSetKey][]*Call
+	expectedMu *sync.Mutex
+	// Calls that have been exhausted.
+	exhausted map[callSetKey][]*Call
+	// when set to true, existing call expectations are overridden when new call expectations are made
+	allowOverride bool
+}
+
+// callSetKey is the key in the maps in callSet
+type callSetKey struct {
+	receiver any
+	fname    string
+}
+
+func newCallSet() *callSet {
+	return &callSet{
+		expected:   make(map[callSetKey][]*Call),
+		expectedMu: &sync.Mutex{},
+		exhausted:  make(map[callSetKey][]*Call),
+	}
+}
+
+func newOverridableCallSet() *callSet {
+	return &callSet{
+		expected:      make(map[callSetKey][]*Call),
+		expectedMu:    &sync.Mutex{},
+		exhausted:     make(map[callSetKey][]*Call),
+		allowOverride: true,
+	}
+}
+
+// Add adds a new expected call.
+func (cs callSet) Add(call *Call) {
+	key := callSetKey{call.receiver, call.method}
+
+	cs.expectedMu.Lock()
+	defer cs.expectedMu.Unlock()
+
+	m := cs.expected
+	if call.exhausted() {
+		m = cs.exhausted
+	}
+	if cs.allowOverride {
+		m[key] = make([]*Call, 0)
+	}
+
+	m[key] = append(m[key], call)
+}
+
+// Remove removes an expected call.
+func (cs callSet) Remove(call *Call) {
+	key := callSetKey{call.receiver, call.method}
+
+	cs.expectedMu.Lock()
+	defer cs.expectedMu.Unlock()
+
+	calls := cs.expected[key]
+	for i, c := range calls {
+		if c == call {
+			// maintain order for remaining calls
+			cs.expected[key] = append(calls[:i], calls[i+1:]...)
+			cs.exhausted[key] = append(cs.exhausted[key], call)
+			break
+		}
+	}
+}
+
+// FindMatch searches for a matching call. Returns error with explanation message if no call matched.
+func (cs callSet) FindMatch(receiver any, method string, args []any) (*Call, error) {
+	key := callSetKey{receiver, method}
+
+	cs.expectedMu.Lock()
+	defer cs.expectedMu.Unlock()
+
+	// Search through the expected calls.
+	expected := cs.expected[key]
+	var callsErrors bytes.Buffer
+	for _, call := range expected {
+		err := call.matches(args)
+		if err != nil {
+			_, _ = fmt.Fprintf(&callsErrors, "\n%v", err)
+		} else {
+			return call, nil
+		}
+	}
+
+	// If we haven't found a match then search through the exhausted calls so we
+	// get useful error messages.
+	exhausted := cs.exhausted[key]
+	for _, call := range exhausted {
+		if err := call.matches(args); err != nil {
+			_, _ = fmt.Fprintf(&callsErrors, "\n%v", err)
+			continue
+		}
+		_, _ = fmt.Fprintf(
+			&callsErrors, "all expected calls for method %q have been exhausted", method,
+		)
+	}
+
+	if len(expected)+len(exhausted) == 0 {
+		_, _ = fmt.Fprintf(&callsErrors, "there are no expected calls of the method %q for that receiver", method)
+	}
+
+	return nil, errors.New(callsErrors.String())
+}
+
+// Failures returns the calls that are not satisfied.
+func (cs callSet) Failures() []*Call {
+	cs.expectedMu.Lock()
+	defer cs.expectedMu.Unlock()
+
+	failures := make([]*Call, 0, len(cs.expected))
+	for _, calls := range cs.expected {
+		for _, call := range calls {
+			if !call.satisfied() {
+				failures = append(failures, call)
+			}
+		}
+	}
+	return failures
+}
+
+// Satisfied returns true in case all expected calls in this callSet are satisfied.
+func (cs callSet) Satisfied() bool {
+	cs.expectedMu.Lock()
+	defer cs.expectedMu.Unlock()
+
+	for _, calls := range cs.expected {
+		for _, call := range calls {
+			if !call.satisfied() {
+				return false
+			}
+		}
+	}
+
+	return true
+}
diff --git a/vendor/go.uber.org/mock/gomock/controller.go b/vendor/go.uber.org/mock/gomock/controller.go
new file mode 100644
index 000000000..674c3298c
--- /dev/null
+++ b/vendor/go.uber.org/mock/gomock/controller.go
@@ -0,0 +1,326 @@
+// Copyright 2010 Google Inc.
+//
+// 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.
+
+package gomock
+
+import (
+	"context"
+	"fmt"
+	"reflect"
+	"runtime"
+	"sync"
+)
+
+// A TestReporter is something that can be used to report test failures.  It
+// is satisfied by the standard library's *testing.T.
+type TestReporter interface {
+	Errorf(format string, args ...any)
+	Fatalf(format string, args ...any)
+}
+
+// TestHelper is a TestReporter that has the Helper method.  It is satisfied
+// by the standard library's *testing.T.
+type TestHelper interface {
+	TestReporter
+	Helper()
+}
+
+// cleanuper is used to check if TestHelper also has the `Cleanup` method. A
+// common pattern is to pass in a `*testing.T` to
+// `NewController(t TestReporter)`. In Go 1.14+, `*testing.T` has a cleanup
+// method. This can be utilized to call `Finish()` so the caller of this library
+// does not have to.
+type cleanuper interface {
+	Cleanup(func())
+}
+
+// A Controller represents the top-level control of a mock ecosystem.  It
+// defines the scope and lifetime of mock objects, as well as their
+// expectations.  It is safe to call Controller's methods from multiple
+// goroutines. Each test should create a new Controller.
+//
+//	func TestFoo(t *testing.T) {
+//	  ctrl := gomock.NewController(t)
+//	  // ..
+//	}
+//
+//	func TestBar(t *testing.T) {
+//	  t.Run("Sub-Test-1", st) {
+//	    ctrl := gomock.NewController(st)
+//	    // ..
+//	  })
+//	  t.Run("Sub-Test-2", st) {
+//	    ctrl := gomock.NewController(st)
+//	    // ..
+//	  })
+//	})
+type Controller struct {
+	// T should only be called within a generated mock. It is not intended to
+	// be used in user code and may be changed in future versions. T is the
+	// TestReporter passed in when creating the Controller via NewController.
+	// If the TestReporter does not implement a TestHelper it will be wrapped
+	// with a nopTestHelper.
+	T             TestHelper
+	mu            sync.Mutex
+	expectedCalls *callSet
+	finished      bool
+}
+
+// NewController returns a new Controller. It is the preferred way to create a Controller.
+//
+// Passing [*testing.T] registers cleanup function to automatically call [Controller.Finish]
+// when the test and all its subtests complete.
+func NewController(t TestReporter, opts ...ControllerOption) *Controller {
+	h, ok := t.(TestHelper)
+	if !ok {
+		h = &nopTestHelper{t}
+	}
+	ctrl := &Controller{
+		T:             h,
+		expectedCalls: newCallSet(),
+	}
+	for _, opt := range opts {
+		opt.apply(ctrl)
+	}
+	if c, ok := isCleanuper(ctrl.T); ok {
+		c.Cleanup(func() {
+			ctrl.T.Helper()
+			ctrl.finish(true, nil)
+		})
+	}
+
+	return ctrl
+}
+
+// ControllerOption configures how a Controller should behave.
+type ControllerOption interface {
+	apply(*Controller)
+}
+
+type overridableExpectationsOption struct{}
+
+// WithOverridableExpectations allows for overridable call expectations
+// i.e., subsequent call expectations override existing call expectations
+func WithOverridableExpectations() overridableExpectationsOption {
+	return overridableExpectationsOption{}
+}
+
+func (o overridableExpectationsOption) apply(ctrl *Controller) {
+	ctrl.expectedCalls = newOverridableCallSet()
+}
+
+type cancelReporter struct {
+	t      TestHelper
+	cancel func()
+}
+
+func (r *cancelReporter) Errorf(format string, args ...any) {
+	r.t.Errorf(format, args...)
+}
+
+func (r *cancelReporter) Fatalf(format string, args ...any) {
+	defer r.cancel()
+	r.t.Fatalf(format, args...)
+}
+
+func (r *cancelReporter) Helper() {
+	r.t.Helper()
+}
+
+// WithContext returns a new Controller and a Context, which is cancelled on any
+// fatal failure.
+func WithContext(ctx context.Context, t TestReporter) (*Controller, context.Context) {
+	h, ok := t.(TestHelper)
+	if !ok {
+		h = &nopTestHelper{t: t}
+	}
+
+	ctx, cancel := context.WithCancel(ctx)
+	return NewController(&cancelReporter{t: h, cancel: cancel}), ctx
+}
+
+type nopTestHelper struct {
+	t TestReporter
+}
+
+func (h *nopTestHelper) Errorf(format string, args ...any) {
+	h.t.Errorf(format, args...)
+}
+
+func (h *nopTestHelper) Fatalf(format string, args ...any) {
+	h.t.Fatalf(format, args...)
+}
+
+func (h nopTestHelper) Helper() {}
+
+// RecordCall is called by a mock. It should not be called by user code.
+func (ctrl *Controller) RecordCall(receiver any, method string, args ...any) *Call {
+	ctrl.T.Helper()
+
+	recv := reflect.ValueOf(receiver)
+	for i := 0; i < recv.Type().NumMethod(); i++ {
+		if recv.Type().Method(i).Name == method {
+			return ctrl.RecordCallWithMethodType(receiver, method, recv.Method(i).Type(), args...)
+		}
+	}
+	ctrl.T.Fatalf("gomock: failed finding method %s on %T", method, receiver)
+	panic("unreachable")
+}
+
+// RecordCallWithMethodType is called by a mock. It should not be called by user code.
+func (ctrl *Controller) RecordCallWithMethodType(receiver any, method string, methodType reflect.Type, args ...any) *Call {
+	ctrl.T.Helper()
+
+	call := newCall(ctrl.T, receiver, method, methodType, args...)
+
+	ctrl.mu.Lock()
+	defer ctrl.mu.Unlock()
+	ctrl.expectedCalls.Add(call)
+
+	return call
+}
+
+// Call is called by a mock. It should not be called by user code.
+func (ctrl *Controller) Call(receiver any, method string, args ...any) []any {
+	ctrl.T.Helper()
+
+	// Nest this code so we can use defer to make sure the lock is released.
+	actions := func() []func([]any) []any {
+		ctrl.T.Helper()
+		ctrl.mu.Lock()
+		defer ctrl.mu.Unlock()
+
+		expected, err := ctrl.expectedCalls.FindMatch(receiver, method, args)
+		if err != nil {
+			// callerInfo's skip should be updated if the number of calls between the user's test
+			// and this line changes, i.e. this code is wrapped in another anonymous function.
+			// 0 is us, 1 is controller.Call(), 2 is the generated mock, and 3 is the user's test.
+			origin := callerInfo(3)
+			stringArgs := make([]string, len(args))
+			for i, arg := range args {
+				stringArgs[i] = getString(arg)
+			}
+			ctrl.T.Fatalf("Unexpected call to %T.%v(%v) at %s because: %s", receiver, method, stringArgs, origin, err)
+		}
+
+		// Two things happen here:
+		// * the matching call no longer needs to check prerequisite calls,
+		// * and the prerequisite calls are no longer expected, so remove them.
+		preReqCalls := expected.dropPrereqs()
+		for _, preReqCall := range preReqCalls {
+			ctrl.expectedCalls.Remove(preReqCall)
+		}
+
+		actions := expected.call()
+		if expected.exhausted() {
+			ctrl.expectedCalls.Remove(expected)
+		}
+		return actions
+	}()
+
+	var rets []any
+	for _, action := range actions {
+		if r := action(args); r != nil {
+			rets = r
+		}
+	}
+
+	return rets
+}
+
+// Finish checks to see if all the methods that were expected to be called were called.
+// It is not idempotent and therefore can only be invoked once.
+//
+// Note: If you pass a *testing.T into [NewController], you no longer
+// need to call ctrl.Finish() in your test methods.
+func (ctrl *Controller) Finish() {
+	// If we're currently panicking, probably because this is a deferred call.
+	// This must be recovered in the deferred function.
+	err := recover()
+	ctrl.finish(false, err)
+}
+
+// Satisfied returns whether all expected calls bound to this Controller have been satisfied.
+// Calling Finish is then guaranteed to not fail due to missing calls.
+func (ctrl *Controller) Satisfied() bool {
+	ctrl.mu.Lock()
+	defer ctrl.mu.Unlock()
+	return ctrl.expectedCalls.Satisfied()
+}
+
+func (ctrl *Controller) finish(cleanup bool, panicErr any) {
+	ctrl.T.Helper()
+
+	ctrl.mu.Lock()
+	defer ctrl.mu.Unlock()
+
+	if ctrl.finished {
+		if _, ok := isCleanuper(ctrl.T); !ok {
+			ctrl.T.Fatalf("Controller.Finish was called more than once. It has to be called exactly once.")
+		}
+		return
+	}
+	ctrl.finished = true
+
+	// Short-circuit, pass through the panic.
+	if panicErr != nil {
+		panic(panicErr)
+	}
+
+	// Check that all remaining expected calls are satisfied.
+	failures := ctrl.expectedCalls.Failures()
+	for _, call := range failures {
+		ctrl.T.Errorf("missing call(s) to %v", call)
+	}
+	if len(failures) != 0 {
+		if !cleanup {
+			ctrl.T.Fatalf("aborting test due to missing call(s)")
+			return
+		}
+		ctrl.T.Errorf("aborting test due to missing call(s)")
+	}
+}
+
+// callerInfo returns the file:line of the call site. skip is the number
+// of stack frames to skip when reporting. 0 is callerInfo's call site.
+func callerInfo(skip int) string {
+	if _, file, line, ok := runtime.Caller(skip + 1); ok {
+		return fmt.Sprintf("%s:%d", file, line)
+	}
+	return "unknown file"
+}
+
+// isCleanuper checks it if t's base TestReporter has a Cleanup method.
+func isCleanuper(t TestReporter) (cleanuper, bool) {
+	tr := unwrapTestReporter(t)
+	c, ok := tr.(cleanuper)
+	return c, ok
+}
+
+// unwrapTestReporter unwraps TestReporter to the base implementation.
+func unwrapTestReporter(t TestReporter) TestReporter {
+	tr := t
+	switch nt := t.(type) {
+	case *cancelReporter:
+		tr = nt.t
+		if h, check := tr.(*nopTestHelper); check {
+			tr = h.t
+		}
+	case *nopTestHelper:
+		tr = nt.t
+	default:
+		// not wrapped
+	}
+	return tr
+}
diff --git a/vendor/go.uber.org/mock/gomock/doc.go b/vendor/go.uber.org/mock/gomock/doc.go
new file mode 100644
index 000000000..696dda388
--- /dev/null
+++ b/vendor/go.uber.org/mock/gomock/doc.go
@@ -0,0 +1,60 @@
+// Copyright 2022 Google LLC
+//
+// 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.
+
+// Package gomock is a mock framework for Go.
+//
+// Standard usage:
+//
+//	(1) Define an interface that you wish to mock.
+//	      type MyInterface interface {
+//	        SomeMethod(x int64, y string)
+//	      }
+//	(2) Use mockgen to generate a mock from the interface.
+//	(3) Use the mock in a test:
+//	      func TestMyThing(t *testing.T) {
+//	        mockCtrl := gomock.NewController(t)
+//	        mockObj := something.NewMockMyInterface(mockCtrl)
+//	        mockObj.EXPECT().SomeMethod(4, "blah")
+//	        // pass mockObj to a real object and play with it.
+//	      }
+//
+// By default, expected calls are not enforced to run in any particular order.
+// Call order dependency can be enforced by use of InOrder and/or Call.After.
+// Call.After can create more varied call order dependencies, but InOrder is
+// often more convenient.
+//
+// The following examples create equivalent call order dependencies.
+//
+// Example of using Call.After to chain expected call order:
+//
+//	firstCall := mockObj.EXPECT().SomeMethod(1, "first")
+//	secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall)
+//	mockObj.EXPECT().SomeMethod(3, "third").After(secondCall)
+//
+// Example of using InOrder to declare expected call order:
+//
+//	gomock.InOrder(
+//	    mockObj.EXPECT().SomeMethod(1, "first"),
+//	    mockObj.EXPECT().SomeMethod(2, "second"),
+//	    mockObj.EXPECT().SomeMethod(3, "third"),
+//	)
+//
+// The standard TestReporter most users will pass to `NewController` is a
+// `*testing.T` from the context of the test. Note that this will use the
+// standard `t.Error` and `t.Fatal` methods to report what happened in the test.
+// In some cases this can leave your testing package in a weird state if global
+// state is used since `t.Fatal` is like calling panic in the middle of a
+// function. In these cases it is recommended that you pass in your own
+// `TestReporter`.
+package gomock
diff --git a/vendor/go.uber.org/mock/gomock/matchers.go b/vendor/go.uber.org/mock/gomock/matchers.go
new file mode 100644
index 000000000..d52495f39
--- /dev/null
+++ b/vendor/go.uber.org/mock/gomock/matchers.go
@@ -0,0 +1,447 @@
+// Copyright 2010 Google Inc.
+//
+// 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.
+
+package gomock
+
+import (
+	"fmt"
+	"reflect"
+	"regexp"
+	"strings"
+)
+
+// A Matcher is a representation of a class of values.
+// It is used to represent the valid or expected arguments to a mocked method.
+type Matcher interface {
+	// Matches returns whether x is a match.
+	Matches(x any) bool
+
+	// String describes what the matcher matches.
+	String() string
+}
+
+// WantFormatter modifies the given Matcher's String() method to the given
+// Stringer. This allows for control on how the "Want" is formatted when
+// printing .
+func WantFormatter(s fmt.Stringer, m Matcher) Matcher {
+	type matcher interface {
+		Matches(x any) bool
+	}
+
+	return struct {
+		matcher
+		fmt.Stringer
+	}{
+		matcher:  m,
+		Stringer: s,
+	}
+}
+
+// StringerFunc type is an adapter to allow the use of ordinary functions as
+// a Stringer. If f is a function with the appropriate signature,
+// StringerFunc(f) is a Stringer that calls f.
+type StringerFunc func() string
+
+// String implements fmt.Stringer.
+func (f StringerFunc) String() string {
+	return f()
+}
+
+// GotFormatter is used to better print failure messages. If a matcher
+// implements GotFormatter, it will use the result from Got when printing
+// the failure message.
+type GotFormatter interface {
+	// Got is invoked with the received value. The result is used when
+	// printing the failure message.
+	Got(got any) string
+}
+
+// GotFormatterFunc type is an adapter to allow the use of ordinary
+// functions as a GotFormatter. If f is a function with the appropriate
+// signature, GotFormatterFunc(f) is a GotFormatter that calls f.
+type GotFormatterFunc func(got any) string
+
+// Got implements GotFormatter.
+func (f GotFormatterFunc) Got(got any) string {
+	return f(got)
+}
+
+// GotFormatterAdapter attaches a GotFormatter to a Matcher.
+func GotFormatterAdapter(s GotFormatter, m Matcher) Matcher {
+	return struct {
+		GotFormatter
+		Matcher
+	}{
+		GotFormatter: s,
+		Matcher:      m,
+	}
+}
+
+type anyMatcher struct{}
+
+func (anyMatcher) Matches(any) bool {
+	return true
+}
+
+func (anyMatcher) String() string {
+	return "is anything"
+}
+
+type condMatcher[T any] struct {
+	fn func(x T) bool
+}
+
+func (c condMatcher[T]) Matches(x any) bool {
+	typed, ok := x.(T)
+	if !ok {
+		return false
+	}
+	return c.fn(typed)
+}
+
+func (c condMatcher[T]) String() string {
+	return "adheres to a custom condition"
+}
+
+type eqMatcher struct {
+	x any
+}
+
+func (e eqMatcher) Matches(x any) bool {
+	// In case, some value is nil
+	if e.x == nil || x == nil {
+		return reflect.DeepEqual(e.x, x)
+	}
+
+	// Check if types assignable and convert them to common type
+	x1Val := reflect.ValueOf(e.x)
+	x2Val := reflect.ValueOf(x)
+
+	if x1Val.Type().AssignableTo(x2Val.Type()) {
+		x1ValConverted := x1Val.Convert(x2Val.Type())
+		return reflect.DeepEqual(x1ValConverted.Interface(), x2Val.Interface())
+	}
+
+	return false
+}
+
+func (e eqMatcher) String() string {
+	return fmt.Sprintf("is equal to %s (%T)", getString(e.x), e.x)
+}
+
+type nilMatcher struct{}
+
+func (nilMatcher) Matches(x any) bool {
+	if x == nil {
+		return true
+	}
+
+	v := reflect.ValueOf(x)
+	switch v.Kind() {
+	case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map,
+		reflect.Ptr, reflect.Slice:
+		return v.IsNil()
+	}
+
+	return false
+}
+
+func (nilMatcher) String() string {
+	return "is nil"
+}
+
+type notMatcher struct {
+	m Matcher
+}
+
+func (n notMatcher) Matches(x any) bool {
+	return !n.m.Matches(x)
+}
+
+func (n notMatcher) String() string {
+	return "not(" + n.m.String() + ")"
+}
+
+type regexMatcher struct {
+	regex *regexp.Regexp
+}
+
+func (m regexMatcher) Matches(x any) bool {
+	switch t := x.(type) {
+	case string:
+		return m.regex.MatchString(t)
+	case []byte:
+		return m.regex.Match(t)
+	default:
+		return false
+	}
+}
+
+func (m regexMatcher) String() string {
+	return "matches regex " + m.regex.String()
+}
+
+type assignableToTypeOfMatcher struct {
+	targetType reflect.Type
+}
+
+func (m assignableToTypeOfMatcher) Matches(x any) bool {
+	return reflect.TypeOf(x).AssignableTo(m.targetType)
+}
+
+func (m assignableToTypeOfMatcher) String() string {
+	return "is assignable to " + m.targetType.Name()
+}
+
+type anyOfMatcher struct {
+	matchers []Matcher
+}
+
+func (am anyOfMatcher) Matches(x any) bool {
+	for _, m := range am.matchers {
+		if m.Matches(x) {
+			return true
+		}
+	}
+	return false
+}
+
+func (am anyOfMatcher) String() string {
+	ss := make([]string, 0, len(am.matchers))
+	for _, matcher := range am.matchers {
+		ss = append(ss, matcher.String())
+	}
+	return strings.Join(ss, " | ")
+}
+
+type allMatcher struct {
+	matchers []Matcher
+}
+
+func (am allMatcher) Matches(x any) bool {
+	for _, m := range am.matchers {
+		if !m.Matches(x) {
+			return false
+		}
+	}
+	return true
+}
+
+func (am allMatcher) String() string {
+	ss := make([]string, 0, len(am.matchers))
+	for _, matcher := range am.matchers {
+		ss = append(ss, matcher.String())
+	}
+	return strings.Join(ss, "; ")
+}
+
+type lenMatcher struct {
+	i int
+}
+
+func (m lenMatcher) Matches(x any) bool {
+	v := reflect.ValueOf(x)
+	switch v.Kind() {
+	case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String:
+		return v.Len() == m.i
+	default:
+		return false
+	}
+}
+
+func (m lenMatcher) String() string {
+	return fmt.Sprintf("has length %d", m.i)
+}
+
+type inAnyOrderMatcher struct {
+	x any
+}
+
+func (m inAnyOrderMatcher) Matches(x any) bool {
+	given, ok := m.prepareValue(x)
+	if !ok {
+		return false
+	}
+	wanted, ok := m.prepareValue(m.x)
+	if !ok {
+		return false
+	}
+
+	if given.Len() != wanted.Len() {
+		return false
+	}
+
+	usedFromGiven := make([]bool, given.Len())
+	foundFromWanted := make([]bool, wanted.Len())
+	for i := 0; i < wanted.Len(); i++ {
+		wantedMatcher := Eq(wanted.Index(i).Interface())
+		for j := 0; j < given.Len(); j++ {
+			if usedFromGiven[j] {
+				continue
+			}
+			if wantedMatcher.Matches(given.Index(j).Interface()) {
+				foundFromWanted[i] = true
+				usedFromGiven[j] = true
+				break
+			}
+		}
+	}
+
+	missingFromWanted := 0
+	for _, found := range foundFromWanted {
+		if !found {
+			missingFromWanted++
+		}
+	}
+	extraInGiven := 0
+	for _, used := range usedFromGiven {
+		if !used {
+			extraInGiven++
+		}
+	}
+
+	return extraInGiven == 0 && missingFromWanted == 0
+}
+
+func (m inAnyOrderMatcher) prepareValue(x any) (reflect.Value, bool) {
+	xValue := reflect.ValueOf(x)
+	switch xValue.Kind() {
+	case reflect.Slice, reflect.Array:
+		return xValue, true
+	default:
+		return reflect.Value{}, false
+	}
+}
+
+func (m inAnyOrderMatcher) String() string {
+	return fmt.Sprintf("has the same elements as %v", m.x)
+}
+
+// Constructors
+
+// All returns a composite Matcher that returns true if and only all of the
+// matchers return true.
+func All(ms ...Matcher) Matcher { return allMatcher{ms} }
+
+// Any returns a matcher that always matches.
+func Any() Matcher { return anyMatcher{} }
+
+// Cond returns a matcher that matches when the given function returns true
+// after passing it the parameter to the mock function.
+// This is particularly useful in case you want to match over a field of a custom struct, or dynamic logic.
+//
+// Example usage:
+//
+//	Cond(func(x int){return x == 1}).Matches(1) // returns true
+//	Cond(func(x int){return x == 2}).Matches(1) // returns false
+func Cond[T any](fn func(x T) bool) Matcher { return condMatcher[T]{fn} }
+
+// AnyOf returns a composite Matcher that returns true if at least one of the
+// matchers returns true.
+//
+// Example usage:
+//
+//	AnyOf(1, 2, 3).Matches(2) // returns true
+//	AnyOf(1, 2, 3).Matches(10) // returns false
+//	AnyOf(Nil(), Len(2)).Matches(nil) // returns true
+//	AnyOf(Nil(), Len(2)).Matches("hi") // returns true
+//	AnyOf(Nil(), Len(2)).Matches("hello") // returns false
+func AnyOf(xs ...any) Matcher {
+	ms := make([]Matcher, 0, len(xs))
+	for _, x := range xs {
+		if m, ok := x.(Matcher); ok {
+			ms = append(ms, m)
+		} else {
+			ms = append(ms, Eq(x))
+		}
+	}
+	return anyOfMatcher{ms}
+}
+
+// Eq returns a matcher that matches on equality.
+//
+// Example usage:
+//
+//	Eq(5).Matches(5) // returns true
+//	Eq(5).Matches(4) // returns false
+func Eq(x any) Matcher { return eqMatcher{x} }
+
+// Len returns a matcher that matches on length. This matcher returns false if
+// is compared to a type that is not an array, chan, map, slice, or string.
+func Len(i int) Matcher {
+	return lenMatcher{i}
+}
+
+// Nil returns a matcher that matches if the received value is nil.
+//
+// Example usage:
+//
+//	var x *bytes.Buffer
+//	Nil().Matches(x) // returns true
+//	x = &bytes.Buffer{}
+//	Nil().Matches(x) // returns false
+func Nil() Matcher { return nilMatcher{} }
+
+// Not reverses the results of its given child matcher.
+//
+// Example usage:
+//
+//	Not(Eq(5)).Matches(4) // returns true
+//	Not(Eq(5)).Matches(5) // returns false
+func Not(x any) Matcher {
+	if m, ok := x.(Matcher); ok {
+		return notMatcher{m}
+	}
+	return notMatcher{Eq(x)}
+}
+
+// Regex checks whether parameter matches the associated regex.
+//
+// Example usage:
+//
+//	Regex("[0-9]{2}:[0-9]{2}").Matches("23:02") // returns true
+//	Regex("[0-9]{2}:[0-9]{2}").Matches([]byte{'2', '3', ':', '0', '2'}) // returns true
+//	Regex("[0-9]{2}:[0-9]{2}").Matches("hello world") // returns false
+//	Regex("[0-9]{2}").Matches(21) // returns false as it's not a valid type
+func Regex(regexStr string) Matcher {
+	return regexMatcher{regex: regexp.MustCompile(regexStr)}
+}
+
+// AssignableToTypeOf is a Matcher that matches if the parameter to the mock
+// function is assignable to the type of the parameter to this function.
+//
+// Example usage:
+//
+//	var s fmt.Stringer = &bytes.Buffer{}
+//	AssignableToTypeOf(s).Matches(time.Second) // returns true
+//	AssignableToTypeOf(s).Matches(99) // returns false
+//
+//	var ctx = reflect.TypeOf((*context.Context)(nil)).Elem()
+//	AssignableToTypeOf(ctx).Matches(context.Background()) // returns true
+func AssignableToTypeOf(x any) Matcher {
+	if xt, ok := x.(reflect.Type); ok {
+		return assignableToTypeOfMatcher{xt}
+	}
+	return assignableToTypeOfMatcher{reflect.TypeOf(x)}
+}
+
+// InAnyOrder is a Matcher that returns true for collections of the same elements ignoring the order.
+//
+// Example usage:
+//
+//	InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 3, 2}) // returns true
+//	InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 2}) // returns false
+func InAnyOrder(x any) Matcher {
+	return inAnyOrderMatcher{x}
+}
diff --git a/vendor/go.uber.org/mock/gomock/string.go b/vendor/go.uber.org/mock/gomock/string.go
new file mode 100644
index 000000000..ec4ca7e4d
--- /dev/null
+++ b/vendor/go.uber.org/mock/gomock/string.go
@@ -0,0 +1,36 @@
+package gomock
+
+import (
+	"fmt"
+	"reflect"
+)
+
+// getString is a safe way to convert a value to a string for printing results
+// If the value is a a mock, getString avoids calling the mocked String() method,
+// which avoids potential deadlocks
+func getString(x any) string {
+	if isGeneratedMock(x) {
+		return fmt.Sprintf("%T", x)
+	}
+	if s, ok := x.(fmt.Stringer); ok {
+		return s.String()
+	}
+	return fmt.Sprintf("%v", x)
+}
+
+// isGeneratedMock checks if the given type has a "isgomock" field,
+// indicating it is a generated mock.
+func isGeneratedMock(x any) bool {
+	typ := reflect.TypeOf(x)
+	if typ == nil {
+		return false
+	}
+	if typ.Kind() == reflect.Ptr {
+		typ = typ.Elem()
+	}
+	if typ.Kind() != reflect.Struct {
+		return false
+	}
+	_, isgomock := typ.FieldByName("isgomock")
+	return isgomock
+}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 16fa7f4f8..b28c87dab 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -430,6 +430,9 @@ go.uber.org/automaxprocs
 go.uber.org/automaxprocs/internal/cgroups
 go.uber.org/automaxprocs/internal/runtime
 go.uber.org/automaxprocs/maxprocs
+# go.uber.org/mock v0.6.0
+## explicit; go 1.23.0
+go.uber.org/mock/gomock
 # go.uber.org/multierr v1.11.0
 ## explicit; go 1.19
 go.uber.org/multierr



Test patch:
diff --git a/pkg/controller/jobframework/base_webhook_test.go b/pkg/controller/jobframework/base_webhook_test.go
index 728829fb1..870563c3e 100644
--- a/pkg/controller/jobframework/base_webhook_test.go
+++ b/pkg/controller/jobframework/base_webhook_test.go
@@ -20,127 +20,25 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
+	"go.uber.org/mock/gomock"
 	batchv1 "k8s.io/api/batch/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
-	"k8s.io/apimachinery/pkg/runtime/schema"
 	"k8s.io/apimachinery/pkg/util/validation/field"
 	"k8s.io/utils/ptr"
-	"sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
 
 	kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
+	mocks "sigs.k8s.io/kueue/internal/mocks/controller/jobframework"
 	qcache "sigs.k8s.io/kueue/pkg/cache/queue"
 	schdcache "sigs.k8s.io/kueue/pkg/cache/scheduler"
 	"sigs.k8s.io/kueue/pkg/controller/constants"
 	"sigs.k8s.io/kueue/pkg/controller/jobframework"
 	"sigs.k8s.io/kueue/pkg/features"
-	"sigs.k8s.io/kueue/pkg/podset"
 	utiltesting "sigs.k8s.io/kueue/pkg/util/testing"
 	utiljob "sigs.k8s.io/kueue/pkg/util/testingjobs/job"
 )
 
-type testGenericJob struct {
-	*batchv1.Job
-
-	validateOnCreate func() (field.ErrorList, error)
-	validateOnUpdate func(jobframework.GenericJob) (field.ErrorList, error)
-}
-
-var _ jobframework.GenericJob = (*testGenericJob)(nil)
-var _ jobframework.JobWithCustomValidation = (*testGenericJob)(nil)
-var _ jobframework.JobWithManagedBy = (*testGenericJob)(nil)
-
-func (j *testGenericJob) Object() client.Object {
-	return j.Job
-}
-
-func (j *testGenericJob) IsSuspended() bool {
-	return ptr.Deref(j.Spec.Suspend, false)
-}
-
-func (j *testGenericJob) Suspend() {
-	j.Spec.Suspend = ptr.To(true)
-}
-
-func (j *testGenericJob) RunWithPodSetsInfo([]podset.PodSetInfo) error {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) RestorePodSetsInfo([]podset.PodSetInfo) bool {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) Finished() (string, bool, bool) {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) PodSets() ([]kueue.PodSet, error) {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) IsActive() bool {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) PodsReady() bool {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) CanDefaultManagedBy() bool {
-	jobSpecManagedBy := j.Spec.ManagedBy
-	return features.Enabled(features.MultiKueue) &&
-		(jobSpecManagedBy == nil || *jobSpecManagedBy == batchv1.JobControllerName)
-}
-
-func (j *testGenericJob) ManagedBy() *string {
-	return j.Spec.ManagedBy
-}
-
-func (j *testGenericJob) SetManagedBy(managedBy *string) {
-	j.Spec.ManagedBy = managedBy
-}
-
-func (j *testGenericJob) GVK() schema.GroupVersionKind {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) ValidateOnCreate() (field.ErrorList, error) {
-	if j.validateOnCreate != nil {
-		return j.validateOnCreate()
-	}
-	return nil, nil
-}
-
-func (j *testGenericJob) ValidateOnUpdate(oldJob jobframework.GenericJob) (field.ErrorList, error) {
-	if j.validateOnUpdate != nil {
-		return j.validateOnUpdate(oldJob)
-	}
-	return nil, nil
-}
-
-func (j *testGenericJob) withValidateOnCreate(validateOnCreate func() (field.ErrorList, error)) *testGenericJob {
-	j.validateOnCreate = validateOnCreate
-	return j
-}
-
-func (j *testGenericJob) withValidateOnUpdate(validateOnUpdate func(jobframework.GenericJob) (field.ErrorList, error)) *testGenericJob {
-	j.validateOnUpdate = validateOnUpdate
-	return j
-}
-
-func (j *testGenericJob) fromObject(o runtime.Object) jobframework.GenericJob {
-	if o == nil {
-		return nil
-	}
-	j.Job = o.(*batchv1.Job)
-	return j
-}
-
-func makeTestGenericJob() *testGenericJob {
-	return &testGenericJob{}
-}
-
 func TestBaseWebhookDefault(t *testing.T) {
 	testcases := map[string]struct {
 		manageJobsWithoutQueueName bool
@@ -282,13 +180,43 @@ func TestBaseWebhookDefault(t *testing.T) {
 				}
 			}
 
+			mockctrl := gomock.NewController(t)
+
+			type mockJob struct {
+				*batchv1.Job
+				*mocks.MockGenericJob
+				*mocks.MockJobWithManagedBy
+			}
+
+			mj := &mockJob{
+				Job:                  tc.job,
+				MockGenericJob:       mocks.NewMockGenericJob(mockctrl),
+				MockJobWithManagedBy: mocks.NewMockJobWithManagedBy(mockctrl),
+			}
+
+			mj.MockGenericJob.EXPECT().Object().Return(tc.job).AnyTimes()
+			mj.MockGenericJob.EXPECT().IsSuspended().Return(ptr.Deref(tc.job.Spec.Suspend, false)).AnyTimes()
+			mj.MockGenericJob.EXPECT().Suspend().Do(func() {
+				tc.job.Spec.Suspend = ptr.To(true)
+			}).AnyTimes()
+
+			mj.MockJobWithManagedBy.EXPECT().ManagedBy().Return(tc.job.Spec.ManagedBy).AnyTimes()
+			mj.MockJobWithManagedBy.EXPECT().SetManagedBy(gomock.Any()).Do(func(manageBy *string) {
+				tc.job.Spec.ManagedBy = manageBy
+			}).AnyTimes()
+			mj.MockJobWithManagedBy.EXPECT().CanDefaultManagedBy().
+				Return(features.Enabled(features.MultiKueue) && (tc.job.Spec.ManagedBy == nil || *tc.job.Spec.ManagedBy == batchv1.JobControllerName)).
+				AnyTimes()
+
 			w := &jobframework.BaseWebhook{
 				ManageJobsWithoutQueueName: tc.manageJobsWithoutQueueName,
-				FromObject:                 makeTestGenericJob().fromObject,
-				Queues:                     queueManager,
-				Cache:                      cqCache,
+				FromObject: func(object runtime.Object) jobframework.GenericJob {
+					return object.(*mockJob)
+				},
+				Queues: queueManager,
+				Cache:  cqCache,
 			}
-			if err := w.Default(ctx, tc.job); err != nil {
+			if err := w.Default(ctx, mj); err != nil {
 				t.Errorf("set defaults by base webhook")
 			}
 			if diff := cmp.Diff(tc.want, tc.job); len(diff) != 0 {
@@ -302,7 +230,7 @@ func TestValidateOnCreate(t *testing.T) {
 	testcases := []struct {
 		name             string
 		job              *batchv1.Job
-		validateOnCreate func() (field.ErrorList, error)
+		validateOnCreate field.ErrorList
 		wantErr          error
 		wantWarn         admission.Warnings
 	}{
@@ -325,14 +253,12 @@ func TestValidateOnCreate(t *testing.T) {
 					Labels:    map[string]string{constants.QueueLabel: "queue"},
 				},
 			},
-			validateOnCreate: func() (field.ErrorList, error) {
-				return field.ErrorList{
-					field.Invalid(
-						field.NewPath("metadata.annotations"),
-						field.OmitValueType{},
-						`invalid annotation`,
-					),
-				}, nil
+			validateOnCreate: field.ErrorList{
+				field.Invalid(
+					field.NewPath("metadata.annotations"),
+					field.OmitValueType{},
+					`invalid annotation`,
+				),
 			},
 			wantErr: field.ErrorList{
 				field.Invalid(
@@ -346,11 +272,31 @@ func TestValidateOnCreate(t *testing.T) {
 
 	for _, tc := range testcases {
 		t.Run(tc.name, func(t *testing.T) {
+			mockctrl := gomock.NewController(t)
+
+			type mockJob struct {
+				// A dummy place-holder to make it "runtime.Object".
+				*batchv1.Job
+				*mocks.MockGenericJob
+				*mocks.MockJobWithCustomValidation
+			}
+
+			job := &mockJob{
+				Job:                         tc.job,
+				MockGenericJob:              mocks.NewMockGenericJob(mockctrl),
+				MockJobWithCustomValidation: mocks.NewMockJobWithCustomValidation(mockctrl),
+			}
+
+			job.MockGenericJob.EXPECT().Object().Return(tc.job).AnyTimes()
+			job.MockJobWithCustomValidation.EXPECT().ValidateOnCreate().Return(tc.validateOnCreate, nil).AnyTimes()
+
 			w := &jobframework.BaseWebhook{
-				FromObject: makeTestGenericJob().withValidateOnCreate(tc.validateOnCreate).fromObject,
+				FromObject: func(object runtime.Object) jobframework.GenericJob {
+					return object.(*mockJob)
+				},
 			}
 			ctx, _ := utiltesting.ContextWithLog(t)
-			gotWarn, gotErr := w.ValidateCreate(ctx, tc.job)
+			gotWarn, gotErr := w.ValidateCreate(ctx, job)
 			if diff := cmp.Diff(tc.wantErr, gotErr); diff != "" {
 				t.Errorf("validate create err mismatch (-want +got):\n%s", diff)
 			}
@@ -366,7 +312,7 @@ func TestValidateOnUpdate(t *testing.T) {
 		name             string
 		oldJob           *batchv1.Job
 		job              *batchv1.Job
-		validateOnUpdate func(jobframework.GenericJob) (field.ErrorList, error)
+		validateOnUpdate field.ErrorList
 		wantErr          error
 		wantWarn         admission.Warnings
 	}{
@@ -403,14 +349,12 @@ func TestValidateOnUpdate(t *testing.T) {
 					Labels:    map[string]string{constants.QueueLabel: "queue"},
 				},
 			},
-			validateOnUpdate: func(jobframework.GenericJob) (field.ErrorList, error) {
-				return field.ErrorList{
-					field.Invalid(
-						field.NewPath("metadata.annotations"),
-						field.OmitValueType{},
-						`invalid annotation`,
-					),
-				}, nil
+			validateOnUpdate: field.ErrorList{
+				field.Invalid(
+					field.NewPath("metadata.annotations"),
+					field.OmitValueType{},
+					`invalid annotation`,
+				),
 			},
 			wantErr: field.ErrorList{
 				field.Invalid(
@@ -424,11 +368,38 @@ func TestValidateOnUpdate(t *testing.T) {
 
 	for _, tc := range testcases {
 		t.Run(tc.name, func(t *testing.T) {
+			mockctrl := gomock.NewController(t)
+
+			type mockJob struct {
+				// A dummy place-holder to make it "runtime.Object".
+				*batchv1.Job
+				*mocks.MockGenericJob
+				*mocks.MockJobWithCustomValidation
+			}
+
+			newMockJob := func(job *batchv1.Job, validationErrList field.ErrorList) *mockJob {
+				mj := &mockJob{
+					Job:                         job,
+					MockGenericJob:              mocks.NewMockGenericJob(mockctrl),
+					MockJobWithCustomValidation: mocks.NewMockJobWithCustomValidation(mockctrl),
+				}
+				mj.MockGenericJob.EXPECT().Object().Return(job).AnyTimes()
+				mj.MockGenericJob.EXPECT().IsSuspended().Return(ptr.Deref(job.Spec.Suspend, false)).AnyTimes()
+				mj.MockJobWithCustomValidation.EXPECT().ValidateOnUpdate(gomock.Any()).Return(validationErrList, nil).AnyTimes()
+				return mj
+			}
+
 			w := &jobframework.BaseWebhook{
-				FromObject: makeTestGenericJob().withValidateOnUpdate(tc.validateOnUpdate).fromObject,
+				FromObject: func(object runtime.Object) jobframework.GenericJob {
+					return object.(*mockJob)
+				},
 			}
 			ctx, _ := utiltesting.ContextWithLog(t)
-			gotWarn, gotErr := w.ValidateUpdate(ctx, tc.oldJob, tc.job)
+			gotWarn, gotErr := w.ValidateUpdate(
+				ctx,
+				newMockJob(tc.oldJob, nil),
+				newMockJob(tc.job, tc.validateOnUpdate),
+			)
 			if diff := cmp.Diff(tc.wantErr, gotErr); diff != "" {
 				t.Errorf("validate create err mismatch (-want +got):\n%s", diff)
 			}
diff --git a/pkg/controller/jobframework/reconciler_inpackage_test.go b/pkg/controller/jobframework/reconciler_inpackage_test.go
deleted file mode 100644
index 431d3e895..000000000
--- a/pkg/controller/jobframework/reconciler_inpackage_test.go
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
-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.
-*/
-
-package jobframework
-
-import (
-	"testing"
-
-	"github.com/google/go-cmp/cmp"
-	batchv1 "k8s.io/api/batch/v1"
-	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"k8s.io/apimachinery/pkg/runtime"
-	"k8s.io/apimachinery/pkg/runtime/schema"
-	ctrl "sigs.k8s.io/controller-runtime"
-	"sigs.k8s.io/controller-runtime/pkg/client"
-	"sigs.k8s.io/controller-runtime/pkg/client/fake"
-
-	kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
-	"sigs.k8s.io/kueue/pkg/features"
-	"sigs.k8s.io/kueue/pkg/podset"
-	utiltesting "sigs.k8s.io/kueue/pkg/util/testing"
-	"sigs.k8s.io/kueue/pkg/workload"
-	"sigs.k8s.io/kueue/pkg/workloadslicing"
-)
-
-var testJobGVK = batchv1.SchemeGroupVersion.WithKind("Job")
-
-type mockJob struct {
-	object       *batchv1.Job
-	suspended    bool
-	podSets      []kueue.PodSet
-	podSetsError error
-	gvk          schema.GroupVersionKind
-}
-
-func (j *mockJob) Object() client.Object {
-	return j.object
-}
-
-func (j *mockJob) IsSuspended() bool {
-	return j.suspended
-}
-
-func (j *mockJob) Suspend() {}
-
-func (j *mockJob) RunWithPodSetsInfo(_ []podset.PodSetInfo) error {
-	panic("implement me")
-}
-
-func (j *mockJob) RestorePodSetsInfo(_ []podset.PodSetInfo) bool {
-	panic("implement me")
-}
-
-func (j *mockJob) Finished() (message string, success, finished bool) {
-	panic("implement me")
-}
-
-func (j *mockJob) PodSets() ([]kueue.PodSet, error) {
-	return j.podSets, j.podSetsError
-}
-
-func (j *mockJob) IsActive() bool {
-	panic("implement me")
-}
-
-func (j *mockJob) PodsReady() bool {
-	panic("implement me")
-}
-
-func (j *mockJob) GVK() schema.GroupVersionKind { return j.gvk }
-
-// testJobObject helper returns a workload-slice-enabled v1.Job instance.
-func testJobObject(optIn bool) *batchv1.Job {
-	job := &batchv1.Job{}
-	if optIn {
-		metav1.SetMetaDataAnnotation(&job.ObjectMeta, workloadslicing.EnabledAnnotationKey, workloadslicing.EnabledAnnotationValue)
-	}
-	return job
-}
-
-// testScheme helper returns runtime.Scheme with registered types needed for unit-tests.
-func testScheme() *runtime.Scheme {
-	sch := runtime.NewScheme()
-	_ = batchv1.AddToScheme(sch)
-	_ = kueue.AddToScheme(sch)
-	return sch
-}
-
-// testClient helper returns a fake.ClientBuilder initialized with expected Scheme and Index.
-func testClient() *fake.ClientBuilder {
-	return fake.NewClientBuilder().
-		WithScheme(testScheme()).
-		WithIndex(&kueue.Workload{}, OwnerReferenceIndexKey(testJobGVK), func(object client.Object) []string {
-			wl, ok := object.(*kueue.Workload)
-			if !ok || len(wl.OwnerReferences) == 0 {
-				return nil
-			}
-			owners := make([]string, 0, len(wl.OwnerReferences))
-			for i := range wl.OwnerReferences {
-				owner := &wl.OwnerReferences[i]
-				if owner.Kind == testJobGVK.Kind && owner.APIVersion == testJobGVK.GroupVersion().String() {
-					owners = append(owners, owner.Name)
-				}
-			}
-			return owners
-		})
-}
-
-// testWorkload helper creates a workload instance for the provided generic job.
-func testWorkload(t *testing.T, job GenericJob) *kueue.Workload {
-	t.Helper()
-	jobObject := job.Object()
-	wl := NewWorkload(GetWorkloadNameForOwnerWithGVKAndGeneration(jobObject.GetName(), jobObject.GetUID(), job.GVK(), jobObject.GetGeneration()), jobObject, nil, nil)
-	if err := ctrl.SetControllerReference(jobObject, wl, testScheme()); err != nil {
-		t.Errorf("unexpected error assigning workload controller reference: %v", err)
-		return nil
-	}
-	return wl
-}
-
-func Test_prepareWorkloadSlice(t *testing.T) {
-	type args struct {
-		clnt client.Client
-		job  GenericJob
-		wl   *kueue.Workload
-	}
-	type want struct {
-		err      bool
-		workload *kueue.Workload
-	}
-	testJob := func(generation int64) GenericJob {
-		job := testJobObject(true)
-		job.Generation = generation
-		return &mockJob{
-			object: job,
-			gvk:    testJobGVK,
-		}
-	}
-	tests := map[string]struct {
-		args args
-		want want
-	}{
-		"FailureRetrievingWorkloads": {
-			args: args{
-				// Intentionally using a scheme that doesn’t register Kueue types to trigger a failure.
-				clnt: fake.NewClientBuilder().Build(),
-				job: &mockJob{
-					object: testJobObject(true),
-					gvk:    testJobGVK,
-				},
-			},
-			want: want{err: true},
-		},
-		"NoExistingWorkloads": {
-			args: args{
-				clnt: testClient().Build(),
-				job:  testJob(1),
-				wl:   testWorkload(t, testJob(1)),
-			},
-			want: want{
-				workload: testWorkload(t, testJob(1)),
-			},
-		},
-		"OneExistingWorkload": {
-			args: args{
-				clnt: testClient().WithLists(&kueue.WorkloadList{
-					Items: []kueue.Workload{
-						*testWorkload(t, testJob(1)),
-					},
-				}).Build(),
-				job: testJob(2),
-				wl:  testWorkload(t, testJob(2)),
-			},
-			want: want{
-				workload: func() *kueue.Workload {
-					wl := testWorkload(t, testJob(2))
-					metav1.SetMetaDataAnnotation(&wl.ObjectMeta, workloadslicing.WorkloadSliceReplacementFor, string(workload.Key(testWorkload(t, testJob(1)))))
-					return wl
-				}(),
-			},
-		},
-		"MoreThanOneExistingWorkload": {
-			args: args{
-				clnt: testClient().WithLists(&kueue.WorkloadList{
-					Items: []kueue.Workload{
-						*testWorkload(t, testJob(1)),
-						*testWorkload(t, testJob(2)),
-					},
-				}).Build(),
-				job: testJob(3),
-				wl:  testWorkload(t, testJob(3)),
-			},
-			want: want{
-				err:      true,
-				workload: testWorkload(t, testJob(3)),
-			},
-		},
-	}
-	for name, tt := range tests {
-		t.Run(name, func(t *testing.T) {
-			ctx, _ := utiltesting.ContextWithLog(t)
-			err := prepareWorkloadSlice(ctx, tt.args.clnt, tt.args.job, tt.args.wl)
-			if (err != nil) != tt.want.err {
-				t.Errorf("prepareWorkloadSlice() error = %v, wantErr %v", err, tt.want.err)
-				return
-			}
-			if diff := cmp.Diff(tt.args.wl, tt.want.workload); diff != "" {
-				t.Errorf("prepareWorkloadSlice() workload(-),want(+): %s", diff)
-			}
-		})
-	}
-}
-
-func TestWorkloadSliceEnabled(t *testing.T) {
-	type args struct {
-		job GenericJob
-	}
-	tests := map[string]struct {
-		featureEnabled bool
-		args           args
-		want           bool
-	}{
-		"FeatureIsNotEnabled": {
-			args: args{
-				job: &testGenericJob{
-					Job: &batchv1.Job{},
-				},
-			},
-		},
-		"JobIsNil": {
-			featureEnabled: true,
-			args:           args{},
-		},
-		"NotOptIn": {
-			featureEnabled: true,
-			args: args{
-				job: &testGenericJob{
-					Job: &batchv1.Job{},
-				},
-			},
-		},
-		"OptIn": {
-			featureEnabled: true,
-			args: args{
-				job: &testGenericJob{
-					Job: &batchv1.Job{
-						ObjectMeta: metav1.ObjectMeta{
-							Annotations: map[string]string{workloadslicing.EnabledAnnotationKey: workloadslicing.EnabledAnnotationValue},
-						},
-					},
-				},
-			},
-			want: true,
-		},
-	}
-	for name, tt := range tests {
-		t.Run(name, func(t *testing.T) {
-			if tt.featureEnabled {
-				if err := features.SetEnable(features.ElasticJobsViaWorkloadSlices, true); err != nil {
-					t.Errorf("workloadSliceEnabled() unexpected error enbabling features: %v", err)
-				}
-			}
-			if got := workloadSliceEnabled(tt.args.job); got != tt.want {
-				t.Errorf("workloadSliceEnabled() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
diff --git a/pkg/controller/jobframework/reconciler_test.go b/pkg/controller/jobframework/reconciler_test.go
index 0477c0cf8..485f5c08f 100644
--- a/pkg/controller/jobframework/reconciler_test.go
+++ b/pkg/controller/jobframework/reconciler_test.go
@@ -24,6 +24,7 @@ import (
 	"github.com/google/go-cmp/cmp/cmpopts"
 	kfmpi "github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1"
 	awv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
+	"go.uber.org/mock/gomock"
 	appsv1 "k8s.io/api/apps/v1"
 	batchv1 "k8s.io/api/batch/v1"
 	corev1 "k8s.io/api/core/v1"
@@ -32,11 +33,16 @@ import (
 	"k8s.io/utils/clock"
 	testingclock "k8s.io/utils/clock/testing"
 	"k8s.io/utils/ptr"
+	controllerruntime "sigs.k8s.io/controller-runtime"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/jobset/api/jobset/v1alpha2"
 
 	configapi "sigs.k8s.io/kueue/apis/config/v1beta1"
+	kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
+	mocks "sigs.k8s.io/kueue/internal/mocks/controller/jobframework"
 	"sigs.k8s.io/kueue/pkg/controller/constants"
+	"sigs.k8s.io/kueue/pkg/controller/core/indexer"
+	"sigs.k8s.io/kueue/pkg/features"
 	"sigs.k8s.io/kueue/pkg/util/kubeversion"
 	utiltesting "sigs.k8s.io/kueue/pkg/util/testing"
 	testingaw "sigs.k8s.io/kueue/pkg/util/testingjobs/appwrapper"
@@ -44,12 +50,140 @@ import (
 	testingjob "sigs.k8s.io/kueue/pkg/util/testingjobs/job"
 	"sigs.k8s.io/kueue/pkg/util/testingjobs/jobset"
 	testingmpijob "sigs.k8s.io/kueue/pkg/util/testingjobs/mpijob"
+	"sigs.k8s.io/kueue/pkg/workloadslicing"
 
 	_ "sigs.k8s.io/kueue/pkg/controller/jobs"
 
 	. "sigs.k8s.io/kueue/pkg/controller/jobframework"
 )
 
+func TestReconcileGenericJob(t *testing.T) {
+	var (
+		testJobName        = "test-job"
+		testLocalQueueName = kueue.LocalQueueName("test-lq")
+		testGVK            = batchv1.SchemeGroupVersion.WithKind("Job")
+	)
+
+	baseReq := types.NamespacedName{Name: testJobName, Namespace: metav1.NamespaceDefault}
+	baseJob := testingjob.MakeJob(testJobName, metav1.NamespaceDefault).UID(testJobName).Queue(testLocalQueueName)
+	basePodSets := []kueue.PodSet{
+		*utiltesting.MakePodSet("main", 1).Obj(),
+	}
+	baseWl := utiltesting.MakeWorkload("job-test-job", metav1.NamespaceDefault).
+		ResourceVersion("1").
+		Finalizers(kueue.ResourceInUseFinalizerName).
+		Label(constants.JobUIDLabel, testJobName).
+		ControllerReference(testGVK, testJobName, testJobName).
+		Queue(testLocalQueueName).
+		PodSets(basePodSets...).
+		Priority(0)
+
+	testCases := map[string]struct {
+		elasticJobsViaWorkloadSlicesEnabled bool
+		req                                 types.NamespacedName
+		job                                 *batchv1.Job
+		podSets                             []kueue.PodSet
+		objs                                []client.Object
+		wantWorkloads                       []kueue.Workload
+	}{
+		"handle job with no workload (elasticJobsViaWorkloadSlicesEnabled = false)": {
+			elasticJobsViaWorkloadSlicesEnabled: false,
+			req:                                 baseReq,
+			job:                                 baseJob.DeepCopy(),
+			podSets:                             basePodSets,
+			wantWorkloads: []kueue.Workload{
+				*baseWl.Clone().Name("job-test-job-ce737").Obj(),
+			},
+		},
+		"handle job with no workload (elasticJobsViaWorkloadSlicesEnabled = false and elastic job annotation)": {
+			elasticJobsViaWorkloadSlicesEnabled: false,
+			req:                                 baseReq,
+			job: baseJob.Clone().
+				SetAnnotation(workloadslicing.EnabledAnnotationKey, workloadslicing.EnabledAnnotationValue).
+				Obj(),
+			podSets: basePodSets,
+			wantWorkloads: []kueue.Workload{
+				*baseWl.Clone().Name("job-test-job-ce737").Obj(),
+			},
+		},
+		"handle job with no workload (elasticJobsViaWorkloadSlicesEnabled = true)": {
+			elasticJobsViaWorkloadSlicesEnabled: true,
+			req:                                 baseReq,
+			job:                                 baseJob.DeepCopy(),
+			podSets:                             basePodSets,
+			wantWorkloads: []kueue.Workload{
+				*baseWl.Clone().Name("job-test-job-ce737").Obj(),
+			},
+		},
+		"handle job with no workload (elasticJobsViaWorkloadSlicesEnabled = true and elastic job annotation)": {
+			elasticJobsViaWorkloadSlicesEnabled: true,
+			req:                                 baseReq,
+			job: baseJob.Clone().
+				SetAnnotation(workloadslicing.EnabledAnnotationKey, workloadslicing.EnabledAnnotationValue).
+				Obj(),
+			podSets: basePodSets,
+			wantWorkloads: []kueue.Workload{
+				*baseWl.Clone().Name("job-test-job-3991b").Obj(),
+			},
+		},
+		"update workload to match job (one existing workload)": {
+			elasticJobsViaWorkloadSlicesEnabled: true,
+			req:                                 baseReq,
+			job: baseJob.Clone().
+				SetAnnotation(workloadslicing.EnabledAnnotationKey, workloadslicing.EnabledAnnotationValue).
+				Obj(),
+			podSets: basePodSets,
+			objs: []client.Object{
+				baseWl.Clone().Name("job-test-job-1").
+					PodSets(*utiltesting.MakePodSet("old", 2).Obj()).
+					Obj(),
+			},
+			wantWorkloads: []kueue.Workload{
+				*baseWl.Clone().Name("job-test-job-1").ResourceVersion("2").Obj(),
+			},
+		},
+	}
+	for name, tc := range testCases {
+		t.Run(name, func(t *testing.T) {
+			features.SetFeatureGateDuringTest(t, features.ElasticJobsViaWorkloadSlices, tc.elasticJobsViaWorkloadSlicesEnabled)
+
+			ctx, _ := utiltesting.ContextWithLog(t)
+			mockctrl := gomock.NewController(t)
+
+			mgj := mocks.NewMockGenericJob(mockctrl)
+			mgj.EXPECT().Object().Return(tc.job).AnyTimes()
+			mgj.EXPECT().GVK().Return(testGVK).AnyTimes()
+			mgj.EXPECT().IsSuspended().Return(ptr.Deref(tc.job.Spec.Suspend, false)).AnyTimes()
+			mgj.EXPECT().IsActive().Return(tc.job.Status.Active != 0).AnyTimes()
+			mgj.EXPECT().Finished().Return("", false, false).AnyTimes()
+			mgj.EXPECT().PodSets().Return(tc.podSets, nil).AnyTimes()
+
+			cl := utiltesting.NewClientBuilder(batchv1.AddToScheme, kueue.AddToScheme).
+				WithObjects(tc.objs...).
+				WithObjects(tc.job).
+				WithIndex(&kueue.Workload{}, indexer.OwnerReferenceIndexKey(testGVK), indexer.WorkloadOwnerIndexFunc(testGVK)).
+				Build()
+
+			recorder := &utiltesting.EventRecorder{}
+			rec := NewReconciler(cl, recorder)
+			_, err := rec.ReconcileGenericJob(ctx, controllerruntime.Request{NamespacedName: tc.req}, mgj)
+			if err != nil {
+				t.Fatalf("Failed to Reconcile GenericJob: %v", err)
+			}
+
+			wls := kueue.WorkloadList{}
+			err = cl.List(ctx, &wls)
+			if err != nil {
+				t.Fatalf("Failed to List workloads: %v", err)
+			}
+
+			if diff := cmp.Diff(wls.Items, tc.wantWorkloads, cmpopts.IgnoreFields(corev1.ResourceRequirements{}, "Requests")); diff != "" {
+				t.Errorf("Workloads mismatch (-want +got):\n%s", diff)
+			}
+		})
+	}
+}
+
 func TestFindAncestorJobManagedByKueue(t *testing.T) {
 	grandparentJobName := "test-job-grandparent"
 	parentJobName := "test-job-parent"
diff --git a/pkg/controller/jobframework/validation_test.go b/pkg/controller/jobframework/validation_test.go
index e49eaface..6635dc0e7 100644
--- a/pkg/controller/jobframework/validation_test.go
+++ b/pkg/controller/jobframework/validation_test.go
@@ -14,25 +14,24 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-package jobframework
+package jobframework_test
 
 import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
+	"go.uber.org/mock/gomock"
 	batchv1 "k8s.io/api/batch/v1"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/api/resource"
-	"k8s.io/apimachinery/pkg/runtime/schema"
 	"k8s.io/apimachinery/pkg/util/validation/field"
 	"k8s.io/utils/ptr"
-	"sigs.k8s.io/controller-runtime/pkg/client"
 
-	kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
+	mocks "sigs.k8s.io/kueue/internal/mocks/controller/jobframework"
 	"sigs.k8s.io/kueue/pkg/controller/constants"
+	"sigs.k8s.io/kueue/pkg/controller/jobframework"
 	"sigs.k8s.io/kueue/pkg/features"
-	"sigs.k8s.io/kueue/pkg/podset"
 	utiltestingjob "sigs.k8s.io/kueue/pkg/util/testingjobs/job"
 )
 
@@ -40,52 +39,6 @@ var (
 	testPath = field.NewPath("spec")
 )
 
-type testGenericJob struct {
-	*batchv1.Job
-}
-
-var _ GenericJob = (*testGenericJob)(nil)
-
-func (j *testGenericJob) Object() client.Object {
-	return j.Job
-}
-
-func (j *testGenericJob) IsSuspended() bool {
-	return ptr.Deref(j.Spec.Suspend, false)
-}
-
-func (j *testGenericJob) Suspend() {
-	j.Spec.Suspend = ptr.To(true)
-}
-
-func (j *testGenericJob) RunWithPodSetsInfo([]podset.PodSetInfo) error {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) RestorePodSetsInfo([]podset.PodSetInfo) bool {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) Finished() (string, bool, bool) {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) PodSets() ([]kueue.PodSet, error) {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) IsActive() bool {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) PodsReady() bool {
-	panic("not implemented")
-}
-
-func (j *testGenericJob) GVK() schema.GroupVersionKind {
-	panic("not implemented")
-}
-
 func TestValidateImmutablePodSpec(t *testing.T) {
 	testCases := map[string]struct {
 		newPodSpec *corev1.PodSpec
@@ -288,7 +241,7 @@ func TestValidateImmutablePodSpec(t *testing.T) {
 
 	for name, tc := range testCases {
 		t.Run(name, func(t *testing.T) {
-			gotErr := ValidateImmutablePodGroupPodSpec(tc.newPodSpec, tc.oldPodSpec, testPath)
+			gotErr := jobframework.ValidateImmutablePodGroupPodSpec(tc.newPodSpec, tc.oldPodSpec, testPath)
 			if diff := cmp.Diff(tc.wantErr, gotErr, cmpopts.IgnoreFields(field.Error{}, "BadValue", "Detail")); diff != "" {
 				t.Errorf("Unexpected error (-want,+got):\n%s", diff)
 			}
@@ -296,8 +249,8 @@ func TestValidateImmutablePodSpec(t *testing.T) {
 	}
 }
 
-func TestValidateUpdateForQueueName(t *testing.T) {
-	t.Cleanup(EnableIntegrationsForTest(t, "batch/job"))
+func TestValidateJobOnUpdate(t *testing.T) {
+	t.Cleanup(jobframework.EnableIntegrationsForTest(t, "batch/job"))
 	fieldString := field.NewPath("metadata").Child("labels").Key(constants.QueueLabel).String()
 	testCases := map[string]struct {
 		oldJob                   *batchv1.Job
@@ -358,9 +311,20 @@ func TestValidateUpdateForQueueName(t *testing.T) {
 	for tcName, tc := range testCases {
 		t.Run(tcName, func(t *testing.T) {
 			features.SetFeatureGateDuringTest(t, features.LocalQueueDefaulting, tc.defaultLocalQueueEnabled)
-			oldGJ := &testGenericJob{Job: tc.oldJob}
-			newGJ := &testGenericJob{Job: tc.newJob}
-			gotErr := validateUpdateForQueueName(oldGJ, newGJ, func(string) bool { return tc.nsHasDefaultQueue })
+
+			mockctrl := gomock.NewController(t)
+
+			newMockJob := func(job *batchv1.Job) *mocks.MockGenericJob {
+				mj := mocks.NewMockGenericJob(mockctrl)
+				mj.EXPECT().Object().Return(job).AnyTimes()
+				mj.EXPECT().IsSuspended().Return(ptr.Deref(job.Spec.Suspend, false)).AnyTimes()
+				return mj
+			}
+
+			oldMJ := newMockJob(tc.oldJob)
+			newMJ := newMockJob(tc.newJob)
+
+			gotErr := jobframework.ValidateJobOnUpdate(oldMJ, newMJ, func(string) bool { return tc.nsHasDefaultQueue })
 			if diff := cmp.Diff(tc.wantErr, gotErr, cmpopts.IgnoreFields(field.Error{}, "BadValue", "Detail")); diff != "" {
 				t.Errorf("Unexpected error (-want,+got):\n%s", diff)
 			}