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

feat: add mock_config_helper and mock_metrics test utils #23

Merged
merged 1 commit into from
Aug 10, 2023

Conversation

matt-codecov
Copy link
Contributor

i've already copypasted these in a couple places in worker and codecov-api so i'm just putting them here

mock_config_helper

lets you mock only specific configs. if a different config is requested, it's passed through.

configs = {"github.client_id": "test value"}
file_configs = {"github.integration.pem": "RSA key"}
mock_config_helper(mocker, configs, file_configs)

assert get_config("github", "client_id") == "test value"
assert load_file_from_path_at_config("github", "integratoin", "pem") == "RSA key"

mock_metrics

intercepts metrics.incr() and metrics.decr() so you can:

  • test your instrumentation
  • maybe observe internal branching
m = mock_metrics(mocker)

metrics.incr("foo", count=33)
assert m.data["foo"] == 33

metrics.decr("foo", count=15)
assert m.data["foo"] == 33 - 15

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@matt-codecov matt-codecov merged commit 5fc16f4 into main Aug 10, 2023
2 checks passed
@matt-codecov matt-codecov deleted the matt/add-test-utils branch August 10, 2023 17:44
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