data_shifter 0.3.2 → 0.3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/data_shifter/internal/side_effect_guards.rb +26 -2
- data/lib/data_shifter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2c27a241f01fd293278fdd45a9b8d5961d3a9ba304a95f657fd591ab5e2b4d6
|
|
4
|
+
data.tar.gz: 4db9925bd3e55bc8420bab92d9ed92a9e86e868ac0a1151f00b5245bace24319
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 151626dbec0bae6d652a71cfcf814ccd79ee442211275dcfa4e62a8d0de04838376a6c67385826f3c4320126ef28d2ac37889e61d59b12f2d29a794296cc921d
|
|
7
|
+
data.tar.gz: 2a696741fbfde60b730cc29470b4c47063813cd2dd3995726961c1405283f32e38203659625c56316d5dd5d06abe3bb251ad455a96d298ec1f38129e558bb4e0
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
* N/A
|
|
6
6
|
|
|
7
|
+
## [0.3.2.1]
|
|
8
|
+
|
|
9
|
+
* [Bugfix] Dry-run Sidekiq guard restores the previous `Sidekiq::Testing` mode (`fake!`, `inline!`, or `disable!`) instead of always calling `disable!`, which leaked global state and could leave later specs enqueueing work to real Redis.
|
|
10
|
+
|
|
7
11
|
## [0.3.2]
|
|
8
12
|
|
|
9
13
|
* [Bugfix] Rake tasks exit quietly after a failed shift run when the shift already printed its failure summary; failures before that summary are still reported on stderr. Replaces rescuing only `Axn::Failure`, which missed most re-raised exceptions from `run!`.
|
data/README.md
CHANGED
|
@@ -114,7 +114,7 @@ In **dry run** mode, DataShifter automatically blocks or fakes these side effect
|
|
|
114
114
|
| **HTTP** | Blocked via WebMock (`disable_net_connect!`). Allow specific hosts with `allow_external_requests [...]` or `DataShifter.config.allow_external_requests`. |
|
|
115
115
|
| **ActionMailer** | `perform_deliveries = false` (restored after run). |
|
|
116
116
|
| **ActiveJob** | Queue adapter set to `:test` (restored after run). |
|
|
117
|
-
| **Sidekiq** | `Sidekiq::Testing.fake!` (
|
|
117
|
+
| **Sidekiq** | `Sidekiq::Testing.fake!` for the run; previous mode (`fake!`, `inline!`, or `disable!`) is restored after. Only applied if `Sidekiq::Testing` is already loaded. |
|
|
118
118
|
|
|
119
119
|
**Guarding other side effects:** For anything we don't cover (e.g. another service, or allowed HTTP that mutates), use e.g. `return if dry_run?` in your shift. DB changes are always rolled back in dry run; only non-DB side effects need this.
|
|
120
120
|
|
|
@@ -12,7 +12,7 @@ module DataShifter
|
|
|
12
12
|
# production runs never load WebMock. On restore we revert to the previous state (enable!
|
|
13
13
|
# or disable!) so e.g. specs that had WebMock enabled are not left with it disabled.
|
|
14
14
|
# - ActionMailer / ActiveJob / Sidekiq: no extra loading; we only toggle existing config
|
|
15
|
-
# for the duration of the block and restore in ensure
|
|
15
|
+
# for the duration of the block and restore in ensure (Sidekiq restores prior fake/inline/disable).
|
|
16
16
|
module SideEffectGuards
|
|
17
17
|
class << self
|
|
18
18
|
# Applies side-effect guards, yields, then restores. Call only when running in dry run.
|
|
@@ -97,10 +97,23 @@ module DataShifter
|
|
|
97
97
|
def apply_sidekiq(saved)
|
|
98
98
|
return unless Sidekiq::Testing.respond_to?(:fake!)
|
|
99
99
|
|
|
100
|
+
saved[:sidekiq_testing_mode] = capture_sidekiq_testing_mode
|
|
100
101
|
Sidekiq::Testing.fake!
|
|
101
102
|
saved[:sidekiq] = true
|
|
102
103
|
end
|
|
103
104
|
|
|
105
|
+
def capture_sidekiq_testing_mode
|
|
106
|
+
if Sidekiq::Testing.respond_to?(:__test_mode)
|
|
107
|
+
Sidekiq::Testing.__test_mode
|
|
108
|
+
elsif Sidekiq::Testing.fake?
|
|
109
|
+
:fake
|
|
110
|
+
elsif Sidekiq::Testing.inline?
|
|
111
|
+
:inline
|
|
112
|
+
else
|
|
113
|
+
:disable
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
104
117
|
def restore_guards(saved)
|
|
105
118
|
if saved.delete(:webmock)
|
|
106
119
|
(saved.delete(:webmock_was_enabled) ? WebMock.enable! : WebMock.disable!)
|
|
@@ -112,7 +125,18 @@ module DataShifter
|
|
|
112
125
|
|
|
113
126
|
return unless saved.delete(:sidekiq)
|
|
114
127
|
|
|
115
|
-
|
|
128
|
+
restore_sidekiq_testing_mode(saved.delete(:sidekiq_testing_mode))
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def restore_sidekiq_testing_mode(mode)
|
|
132
|
+
case mode
|
|
133
|
+
when :fake
|
|
134
|
+
Sidekiq::Testing.fake!
|
|
135
|
+
when :inline
|
|
136
|
+
Sidekiq::Testing.inline!
|
|
137
|
+
else
|
|
138
|
+
Sidekiq::Testing.disable!
|
|
139
|
+
end
|
|
116
140
|
end
|
|
117
141
|
end
|
|
118
142
|
end
|
data/lib/data_shifter/version.rb
CHANGED