Skip to content

Improve TestHelper's setup/teardown helpers#2116

Merged
st0012 merged 3 commits intomasterfrom
fix-#2103
Sep 26, 2023
Merged

Improve TestHelper's setup/teardown helpers#2116
st0012 merged 3 commits intomasterfrom
fix-#2103

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Sep 24, 2023

Fixes #2103

Currently, TestHelper sets up / tears down tests by mutating the objects on the same layer. With this design, fixing #2103 would require storing the previous values of config and assigning them back after tests, which is error-prone.

So in this PR, I decided to utilise the SDK's layer design in setup_sentry_test:

  1. We make sure the base layer's configuration uses dummy values.
  2. And then we push another layer to the stack, which has a copied dummy configuration as well as a blank scope.
  3. When teardown_sentry_test is called, we can simply pop the layer from 2.

If anything unexpected happens (e.g. users popped the stack themselves), having the base layer created in 1) will make sure no NoMethodError will be thrown or having any data being sent by accident.

@st0012 st0012 added the bug fix label Sep 24, 2023
@st0012 st0012 self-assigned this Sep 24, 2023
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 24, 2023

Codecov Report

Patch has no changes to coverable lines.

Files Changed Coverage
sentry-ruby/lib/sentry/test_helper.rb 0.00%

📢 Thoughts on this report? Let us know!.

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.

Teardown test helper leaves configuration behind

2 participants