Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Automate mock generation #11391

Closed
wants to merge 9 commits into from
Closed

Conversation

WillAbides
Copy link
Contributor

@WillAbides WillAbides commented Nov 21, 2022

This adds //go:generate statements to generate all the mocks I found in this repo. make gogen will now generate mocks and ci will fail when mocks are out of date. I searched for mocks by grepping for // Code generated by mockery and then // Code generated by along with a visual scan for mockgen or other files that looked like they may contain generated mocks.

I chose the newest version of mockery (v2.15.0). I see some of the mocks were previously generated with mockery v1. Mockery v1 doesn't not work with go 1.18+. It doesn't look like there are any breaking changes that affect argo-cd between v1 and v2.

The mocks under pkg/apiclient aren't used in this repo as far as I can tell, however they are part of the public API so I kept them with a note that they are unused here.

Some mocks were outdated, so this PR updates them to correctly implement their interface. This broke expectations in one test, so I updated that test.

I updated the gogen make target to go generate for all directories.

I removed a //go:generate mockgen ... comment that didn't have a corresponding mock.

Closes #11390

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).

WillAbides and others added 6 commits November 21, 2022 10:40
Signed-off-by: Will Roden <will@roden.cc>
Signed-off-by: Will Roden <will@roden.cc>
Signed-off-by: Will Roden <will@roden.cc>
Signed-off-by: Will Roden <will@roden.cc>
Signed-off-by: Will Roden <will@roden.cc>
@codecov
Copy link

codecov bot commented Nov 21, 2022

Codecov Report

Base: 46.95% // Head: 46.95% // No change to project coverage 👍

Coverage data is based on head (d2d5022) compared to base (f80d3be).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #11391   +/-   ##
=======================================
  Coverage   46.95%   46.95%           
=======================================
  Files         242      242           
  Lines       40266    40266           
=======================================
  Hits        18906    18906           
  Misses      19452    19452           
  Partials     1908     1908           
Impacted Files Coverage Δ
controller/cache/cache.go 19.48% <ø> (ø)
pkg/apiclient/apiclient.go 1.18% <ø> (ø)
util/db/db.go 83.78% <ø> (ø)
util/git/client.go 50.93% <ø> (ø)
util/helm/client.go 47.96% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@alexef alexef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I need this. tried it on the branch I'm working on, generated just fine.

Can you fix conflicts with master?

@alexef alexef added type:tech-debt Enhancement invisible for the end user component:test Test requests (e2e or unit) labels Dec 7, 2022
# Conflicts:
#	reposerver/repository/repository_test.go
@WillAbides
Copy link
Contributor Author

@alexef conflict is resolved

@crenshaw-dev
Copy link
Collaborator

@WillAbides looks like we have a small diff on the codegen

Signed-off-by: Will Roden <will@roden.cc>
@WillAbides
Copy link
Contributor Author

@WillAbides looks like we have a small diff on the codegen

Sorry about that. This one should be better 🤞

Copy link
Member

@alexef alexef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♨️

@WillAbides
Copy link
Contributor Author

I'm not familiar enough with the e2e tests to know what's going wrong here. Looking at the history, a similar failure seems to be happening in multiple branches.

@WillAbides
Copy link
Contributor Author

What's the status on getting this merged? Is anything needed from me?

@crenshaw-dev
Copy link
Collaborator

@WillAbides this is very good and very helpful, just a little swamped getting ready for 2.6 RC1 Monday. Will come back to this after. :-)

@crenshaw-dev crenshaw-dev changed the title Automate mock generation chore: Automate mock generation Feb 6, 2023
@jannfis jannfis added the size/M label Mar 11, 2023
@crenshaw-dev
Copy link
Collaborator

@WillAbides would you mind rebasing? I did it locally real quick but don't have permissions to push to your branch.

@blakepettersson
Copy link
Member

Superseded by #18371

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:test Test requests (e2e or unit) size/M type:tech-debt Enhancement invisible for the end user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate mocks with make gogen
5 participants