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: add some audit tests #2489

Merged
merged 5 commits into from
Jan 7, 2023
Merged

Conversation

sozercan
Copy link
Member

@sozercan sozercan commented Jan 3, 2023

Signed-off-by: Sertac Ozercan sozercan@gmail.com

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
related #2453

Special notes for your reviewer:

@sozercan sozercan changed the title add some audit tests tests: add some audit tests Jan 3, 2023
@sozercan sozercan requested a review from a team January 3, 2023 22:48
@sozercan sozercan changed the title tests: add some audit tests test: add some audit tests Jan 3, 2023
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2023

Codecov Report

Base: 53.45% // Head: 53.73% // Increases project coverage by +0.28% 🎉

Coverage data is based on head (6c5e9bd) compared to base (bed335f).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2489      +/-   ##
==========================================
+ Coverage   53.45%   53.73%   +0.28%     
==========================================
  Files         115      115              
  Lines       10196    10196              
==========================================
+ Hits         5450     5479      +29     
+ Misses       4329     4299      -30     
- Partials      417      418       +1     
Flag Coverage Δ
unittests 53.73% <ø> (+0.28%) ⬆️

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

Impacted Files Coverage Δ
pkg/readiness/object_tracker.go 83.98% <0.00%> (+1.06%) ⬆️
pkg/audit/manager.go 4.55% <0.00%> (+3.48%) ⬆️

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.

Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
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.

Thanks for starting to add tests!

We probably want to test the actual auditing logic at some point, but as long as we're not closing the bug.

Only blocking concerns are nits about using t.Run()

pkg/audit/manager_test.go Outdated Show resolved Hide resolved
pkg/audit/manager_test.go Outdated Show resolved Hide resolved
}
}

func Test_getFilesFromDir(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want to test the round-tripping of writing/reading list results in order to catch inconsistencies (since the reading/writing logic is necessarily coupled).

Doing this would probably require some refactoring, which I could see being part of a larger effort later.

Copy link
Member Author

Choose a reason for hiding this comment

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

are we okay to do this as a follow-up?

pkg/audit/manager_test.go Outdated Show resolved Hide resolved
sozercan and others added 2 commits January 6, 2023 22:07
Signed-off-by: Sertac Ozercan <sozercan@gmail.com>
@sozercan
Copy link
Member Author

sozercan commented Jan 6, 2023

We probably want to test the actual auditing logic at some point, but as long as we're not closing the bug.

Yes, these are just quick initial tests that don't require dealing with fake/mock clients. This is not closing the 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

@sozercan sozercan merged commit 4f8b630 into open-policy-agent:master Jan 7, 2023
@sozercan sozercan deleted the tests-audit branch January 7, 2023 01:52
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.

None yet

3 participants