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

Improve code coverage of submodule parsing #873

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

robramsaynz
Copy link
Contributor

This is a PR to improve coverage for submodule parsing that's already in the system. Specifically func getSubmodules in pkg/osvscanner/osvscanner.go.

This is already covered by a fixture based test in pkg/osvscanner/osvscanner_internal_test.go but while have execution inside getSubmodules, it doesn't actually cover the working parts of getSubmodules.

You can see coverage info by running ./scripts/generate_coverage_report.sh and looking in ./coverage.html#file133.

There are a number of states a submodule can be in:

  1. a submodule is setup and checked out
  2. a submodule is setup and but dir is empty
  3. a submodule is setup and and checked out but dir has local changes
  4. a submodule is setup and but dir is set to a different commit

I'm planning to test 1 and 2. I think 3 and 4 are nice to haves, and I plan to only tackle them if they're easy once 1 and 2 are done. Possibly submodules have more possible states, but these seem reasonable for coverage.

I see two implementation options:

@codecov-commenter
Copy link

codecov-commenter commented Mar 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.15%. Comparing base (b28c1c8) to head (9740dd9).
Report is 56 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #873      +/-   ##
==========================================
+ Coverage   59.78%   63.15%   +3.36%     
==========================================
  Files         136      145       +9     
  Lines       11268    11861     +593     
==========================================
+ Hits         6737     7491     +754     
+ Misses       4102     3896     -206     
- Partials      429      474      +45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robramsaynz
Copy link
Contributor Author

I've done a bit more poking and managed to create git-repo with submodules that doesn't have a backing github repo, so re-utilising the existing fixture based testing —func Test_scanGit— looks like the best option at this stage.

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

2 participants