-
Notifications
You must be signed in to change notification settings - Fork 267
Add unit tests for internal/service module #3781
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
base: develop
Are you sure you want to change the base?
Add unit tests for internal/service module #3781
Conversation
fsys := afero.NewMemMapFs() | ||
|
||
// Execute: Call the Run function | ||
err := Run(context.Background(), fsys) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make these tests pass, you need to mock all api requests using gock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it — I’ll use gock to mock the API calls and make the tests pass. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use a fake but valid access token for tests, with #nosec G101 to avoid gosec false positives
- Fix race condition in listRemoteImages by protecting map writes with sync.Mutex
- All tests now pass with
-race
and are CI-friendly
756005e
to
843b8f1
Compare
Pull Request Test Coverage Report for Build 16030849241Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
What
This PR adds a comprehensive test suite for the
internal/services
module.Why
Details
Run()
CheckVersions()
listRemoteImages()
suggestUpdateCmd()
afero.NewMemMapFs()
for in-memory filesystem testinggock
for HTTP request mockingtestify
for assertionsResult
Let me know if you need any changes or improvements!