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

Refactor/mocks sub package #1393

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

Refactor/mocks sub package #1393

wants to merge 4 commits into from

Conversation

mbruzina
Copy link
Contributor

@mbruzina mbruzina commented Nov 11, 2022

This is a draft for introducing some different testing methodologies in an effort to increase test coverage and refactor some of our existing logic.

Starting with /internal/install/discovery, a new mocks directory was introduced, and mocks were built from Discoverer and Validator interfaces using mockery. The end result within the tests appears similar to the previous stubs, but the package is a bit cleaner overall.

Some of the existing mocks in this package seemed a bit odd in how they were used; this led to some refactoring of logic within recipe_installer and focused on removing receiver objects from RecipeInstall that don't really need to be there, such as os discover and manifest validation. These two receivers were extracted into function variables which provides the flexibility to override their implementation in recipe_installer_test as well as remove unnecessary members from RecipeInstall

@codecov
Copy link

codecov bot commented Nov 11, 2022

Codecov Report

Merging #1393 (cfead4c) into main (8a124b1) will increase coverage by 0.32%.
The diff coverage is 97.61%.

❗ Current head cfead4c differs from pull request most recent head 9534cea. Consider uploading reports for the commit 9534cea to get more accurate results

@@            Coverage Diff             @@
##             main    #1393      +/-   ##
==========================================
+ Coverage   47.01%   47.33%   +0.32%     
==========================================
  Files         119      111       -8     
  Lines        7079     6889     -190     
==========================================
- Hits         3328     3261      -67     
+ Misses       3616     3493     -123     
  Partials      135      135              
Impacted Files Coverage Δ
internal/install/mock_recipe_installer.go 16.66% <ø> (+4.16%) ⬆️
internal/install/recipe_installer.go 79.13% <92.30%> (+0.53%) ⬆️
...al/install/discovery/manifest_discovery_service.go 100.00% <100.00%> (ø)
internal/install/discovery/manifest_validator.go 92.50% <100.00%> (ø)
internal/install/license_key_fetcher.go 100.00% <100.00%> (+100.00%) ⬆️
internal/install/recipe_install_builder.go 90.00% <100.00%> (-0.91%) ⬇️
internal/install/validation/agent_validator.go 76.66% <100.00%> (ø)
internal/install/mocks/mock_context.go
...l/install/validation/mocks/mock_agent_validator.go
...ernal/install/validation/mocks/mock_nrdb_client.go
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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.

2 participants