Skip to content

CNF-23386: mockgen deprecated: use uber-go/mock instead#271

Open
sebrandon1 wants to merge 1 commit into
openshift:masterfrom
sebrandon1:mockgen_deprecation
Open

CNF-23386: mockgen deprecated: use uber-go/mock instead#271
sebrandon1 wants to merge 1 commit into
openshift:masterfrom
sebrandon1:mockgen_deprecation

Conversation

@sebrandon1
Copy link
Copy Markdown
Member

@sebrandon1 sebrandon1 commented Nov 13, 2025

https://github.com/golang/mock is marked as archived as of June 27, 2023. They recommend using go.uber.org/mock.

This PR attempts to change the dependency to one that is maintained.

Tracking issue: redhat-best-practices-for-k8s/telco-bot#45

Summary by CodeRabbit

  • Chores

    • Migrated mocking framework from golang/mock to Uber's mockgen tool.
    • Updated Go module dependencies, including upgraded indirect dependencies and addition of new testing utilities.
    • Updated Go version from 1.23 to 1.23.0.
  • Documentation

    • Updated testing documentation to reflect the new mocking framework and installation instructions.
  • Tests

    • Regenerated test mocks with updated tooling to align with the latest client interface specifications.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 32.25806% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.34%. Comparing base (cd99422) to head (b733de2).

Files with missing lines Patch % Lines
pkg/util/mocks/cr-client.go 34.04% 27 Missing and 4 partials ⚠️
pkg/util/mocks/status-writer.go 26.66% 10 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #271   +/-   ##
=======================================
  Coverage   58.34%   58.34%           
=======================================
  Files          26       26           
  Lines        1942     1942           
=======================================
  Hits         1133     1133           
  Misses        731      731           
  Partials       78       78           
Files with missing lines Coverage Δ
...ontrollers/projectclaim/projectclaim_controller.go 64.86% <ø> (ø)
pkg/condition/conditions.go 83.87% <ø> (ø)
pkg/gcpclient/client.go 0.00% <ø> (ø)
pkg/util/mocks/condition/conditions.go 100.00% <ø> (ø)
pkg/util/mocks/gcpclient/client.go 82.75% <ø> (ø)
.../util/mocks/projectclaim/customeresourceadapter.go 78.04% <ø> (ø)
pkg/util/mocks/status-writer.go 38.09% <26.66%> (ø)
pkg/util/mocks/cr-client.go 38.57% <34.04%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sebrandon1
Copy link
Copy Markdown
Member Author

/retest

@sebrandon1 sebrandon1 force-pushed the mockgen_deprecation branch from b036341 to c29b305 Compare March 20, 2026 19:44
@sebrandon1 sebrandon1 changed the title mockgen deprecated: use uber-go/mock instead CNF-23386: mockgen deprecated: use uber-go/mock instead Apr 30, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 30, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 30, 2026

@sebrandon1: This pull request references CNF-23386 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

https://github.com/golang/mock is marked as archived as of June 27, 2023. They recommend using go.uber.org/mock.

This PR attempts to change the dependency to one that is maintained.

Tracking issue: redhat-best-practices-for-k8s/telco-bot#45

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@sebrandon1 sebrandon1 force-pushed the mockgen_deprecation branch from c29b305 to b733de2 Compare May 5, 2026 22:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 14dd2cb8-cb7d-4fe1-8497-c804a7e9f34c

📥 Commits

Reviewing files that changed from the base of the PR and between cd99422 and b733de2.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (13)
  • config/config.go
  • controllers/projectclaim/projectclaim_controller.go
  • docs/testing.md
  • go.mod
  • pkg/condition/conditions.go
  • pkg/gcpclient/client.go
  • pkg/util/mocks/condition/conditions.go
  • pkg/util/mocks/cr-client.go
  • pkg/util/mocks/doc.go
  • pkg/util/mocks/gcpclient/client.go
  • pkg/util/mocks/generate.go
  • pkg/util/mocks/projectclaim/customeresourceadapter.go
  • pkg/util/mocks/status-writer.go

Walkthrough

This PR migrates the project's mock generation tooling from golang/mock to uber-go/mock, updating dependencies, build directives, generated mock files, and documentation to use the new tool and its generated code structure.

Changes

Mock Generation Tool Migration

Layer / File(s) Summary
Dependency Configuration
go.mod
Removed github.com/golang/mock v1.6.0, added github.com/stretchr/testify v1.9.0 and go.uber.org/mock v0.6.0; upgraded indirect golang.org/x/* dependencies (crypto, mod, net, sync, sys, term, text, tools) to newer versions; updated go directive from go 1.23 to go 1.23.0.
Build Generation Directives
controllers/projectclaim/projectclaim_controller.go, pkg/condition/conditions.go, pkg/gcpclient/client.go, pkg/util/mocks/generate.go
Updated //go:generate directives to invoke go run go.uber.org/mock/mockgen instead of standalone mockgen tool; updated installation and tool guidance in mocks/generate.go.
Generated Mock Structure
pkg/util/mocks/condition/conditions.go, pkg/util/mocks/cr-client.go, pkg/util/mocks/gcpclient/client.go, pkg/util/mocks/projectclaim/customeresourceadapter.go, pkg/util/mocks/status-writer.go
Added isgomock struct{} marker field to mock types; updated method signatures to use named parameters (ctx, obj, opts) instead of generic argN notation; updated Create, Delete, Get, List, Patch, Update methods with explicit typed parameters and variadic options; added SubResource method to cr-client mock; updated corresponding recorder methods.
Mock Import Paths
pkg/util/mocks/doc.go
Updated mockgen model import from github.com/golang/mock/mockgen/model to go.uber.org/mock/mockgen/model.
Documentation
docs/testing.md
Updated GoMock repository link from github.com/golang/mock to github.com/uber-go/mock; changed mockgen installation from go get github.com/golang/mock/mockgen@latest to go install go.uber.org/mock/mockgen@v0.6.0.

Configuration Formatting

Layer / File(s) Summary
Whitespace Normalization
config/config.go
Reformatted three const declarations, replacing tab characters with spaces between field names and types; values and semantics unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning Tests violate single responsibility - multiple behaviors in one test. Lack assertion failure messages for debugging aid. Add failure messages to Expect() calls and split multi-behavior tests into separate It blocks.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: migrating from the deprecated golang/mock to uber-go/mock mocking library, which aligns with the primary objective across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed All Ginkgo test names in the PR are stable and deterministic. No dynamic information found in any test titles. All test names use static, descriptive strings.
Microshift Test Compatibility ✅ Passed New Ginkgo tests added use only custom GCP operator CRDs and standard Kubernetes APIs; no MicroShift-incompatible OpenShift APIs (Project, DeploymentConfig, ClusterOperator, etc.) are referenced.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PR only updates mock generation infrastructure and dependencies. No new Ginkgo e2e tests are added, so the check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed Test dependency upgrade only (golang/mock → go.uber.org/mock). No scheduling constraints or pod affinity rules introduced.
Ote Binary Stdout Contract ✅ Passed No OTE Binary Stdout Contract violations found. All changes are to go:generate directives, dependencies, and generated code. No process-level entry points modified.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Check not applicable. PR only updates mocking library (golang/mock to go.uber.org/mock) and generated mocks. No new Ginkgo e2e tests were added.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 5, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sebrandon1
Once this PR has been reviewed and has the lgtm label, please assign nikokolas3270 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 5, 2026

@sebrandon1: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/validate b733de2 link true /test validate

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants