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

test: vendor in testify (again) #2374

Merged
merged 6 commits into from
Nov 3, 2022

Conversation

acpana
Copy link
Contributor

@acpana acpana commented Nov 1, 2022

Signed-off-by: Alex Pana 8968914+acpana@users.noreply.github.com

What this PR does / why we need it:

This patch vendors in:

Also the patch uses testify/require to add some low level unit tests. (I indiscriminately looked for one func/ package w low coverage).

Special notes for your reviewer:

Why?

legend: + = pro; - = con

+ I think testify/require and testify/assert are the more expressive frameworks used in OSS go development for testing. eg1.
+ IMO having this dep and using it actively lowers the barrier to entry for contributions when it comes to testing code.
- testify can be a bit heavy (since it contains a few packages)
- it's not without quirks; for instance: https://tychoish.com/post/against-testify/

@codecov-commenter
Copy link

codecov-commenter commented Nov 1, 2022

Codecov Report

Base: 53.47% // Head: 53.64% // Increases project coverage by +0.17% 🎉

Coverage data is based on head (147b374) compared to base (eb6f434).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2374      +/-   ##
==========================================
+ Coverage   53.47%   53.64%   +0.17%     
==========================================
  Files         117      117              
  Lines       10230    10230              
==========================================
+ Hits         5470     5488      +18     
+ Misses       4341     4325      -16     
+ Partials      419      417       -2     
Flag Coverage Δ
unittests 53.64% <ø> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...onstrainttemplate/constrainttemplate_controller.go 59.09% <0.00%> (+1.91%) ⬆️
pkg/audit/result.go 100.00% <0.00%> (+100.00%) ⬆️

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
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM

@maxsmythe maxsmythe requested review from sozercan and ritazh November 2, 2022 00:48
pkg/audit/result_test.go Outdated Show resolved Hide resolved
Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

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

minor typo, otherwise LGTM

@ritazh
Copy link
Member

ritazh commented Nov 2, 2022

Thanks for adding this @acpana! Is the thought that we would start using testify for new unit tests? Is there a need to move existing tests over? when should we use testify vs existing framework?

Co-authored-by: Sertaç Özercan <852750+sozercan@users.noreply.github.com>
Signed-off-by: alex <8968914+acpana@users.noreply.github.com>
@acpana
Copy link
Contributor Author

acpana commented Nov 2, 2022

Is the thought that we would start using testify for new unit tests?

We could! I am a bit opinionated in that I like the expressivity of a require.NoError(// err or call) for instance. I don't feel strongly about this that said. The more interesting angle for me is encouragement/ familiarity for new contributors to gatekeeper who are used to these framework.

Is there a need to move existing tests over?

I don't think there's a need to embark on a wholesale refactor. But I can be convinced otherwise. I've seen code bases that adopted require where there's a mix of "old stuff" and "new stuff". Old stuff gets updated on a refactor/ as needed basis.

when should we use testify vs existing framework?

I think it depends on you (the maintainers) and if you want to encourage the usage. Personally, I'd use require at least for every new test I'd add but that's just preference 🙃 .

Copy link
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

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

LGTM

@maxsmythe maxsmythe merged commit d9c5e2f into open-policy-agent:master Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants