xenserver / status-report

Program that gathers data for xenserver host diagnostics
GNU Lesser General Public License v2.1
1 stars 9 forks source link

CI: Improve unit tests to test the bugtool's main() as well #44

Closed bernhardkaindl closed 10 months ago

bernhardkaindl commented 10 months ago

This PR raises the code coverage from of the bugtool script itself from 50% to 84% by running almost all of bugtool from a single test module by testing the bugtool's main() function.

This allows for full testing of nearly any other fixes and changes:

Add tests/unit/test_main.py which also uses test functions which were added for earlier tests to test the main function of bugtool to produce the bugtool output archives for all types: zip, tar, and tar.bz2.

The main test checks the output of the bugtool application to ensure that it matches the expected output. It compares the captured output with the expected output and performs various assertions to validate the output.

It extracts the output files from the archive and checks that the xAPI db and the inventory.xml.

Tested output:

codecov-commenter commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (1aae840) 56.52% compared to head (0783b2f) 84.90%. Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #44 +/- ## =========================================== + Coverage 56.52% 84.90% +28.37% =========================================== Files 8 15 +7 Lines 1647 1928 +281 =========================================== + Hits 931 1637 +706 + Misses 716 291 -425 ``` | [Flag](https://app.codecov.io/gh/xenserver/status-report/pull/44/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xenserver) | Coverage Δ | | |---|---|---| | [python2.7](https://app.codecov.io/gh/xenserver/status-report/pull/44/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xenserver) | `83.40% <93.79%> (?)` | | | [python3.10.13](https://app.codecov.io/gh/xenserver/status-report/pull/44/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xenserver) | `83.74% <100.00%> (?)` | | | [unittest](https://app.codecov.io/gh/xenserver/status-report/pull/44/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xenserver) | `83.74% <100.00%> (+27.21%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=xenserver#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

bernhardkaindl commented 10 months ago

@psafont Thank you for your review and approval!

While there's quite a bit of code being introduced, it's just in the tests and not on the deployed code.

This, along with the coverage report that ensure the new code is run, makes the PR low-risk

Exactly, fully agreed!

I just pushed the final minor fixes of the GitHub Workflow file .github/workflows/main.yml!

Could you review the changes? They are: