voxpupuli / rspec-puppet-facts

Simplify your unit tests by looping on every supported Operating System and populating facts.
Apache License 2.0
61 stars 53 forks source link

Collect facts iteratively #152

Closed ekohl closed 1 year ago

ekohl commented 1 year ago

Rather than getting the facts for every filter spec and then discarding that, this stores the found facts in an array and uses that.

This eliminates a call to FacterDB::get_facts with a very complex filter.

A quick test in puppet-nginx reduces loading of tests by about 2 seconds (from ~9 to ~7).

This is a reworked version of https://github.com/voxpupuli/rspec-puppet-facts/pull/124 for a clean changelog. It requires https://github.com/voxpupuli/rspec-puppet-facts/pull/151 to be merged first.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.03 :warning:

Comparison is base (1c8a717) 95.23% compared to head (2bfaa90) 95.20%.

:exclamation: Current head 2bfaa90 differs from pull request most recent head 58fa0a4. Consider uploading reports for the commit 58fa0a4 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #152 +/- ## ========================================== - Coverage 95.23% 95.20% -0.03% ========================================== Files 2 2 Lines 168 167 -1 ========================================== - Hits 160 159 -1 Misses 8 8 ``` | [Impacted Files](https://app.codecov.io/gh/voxpupuli/rspec-puppet-facts/pull/152?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli) | Coverage Δ | | |---|---|---| | [lib/rspec-puppet-facts.rb](https://app.codecov.io/gh/voxpupuli/rspec-puppet-facts/pull/152?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=voxpupuli#diff-bGliL3JzcGVjLXB1cHBldC1mYWN0cy5yYg==) | `98.14% <100.00%> (-0.02%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

ekohl commented 1 year ago

Test failure is because it no longer does the additional get_facts call, which was the whole point.