karafka-testing 2.3.1 → 2.3.2
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
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/karafka/testing/errors.rb +1 -11
- data/lib/karafka/testing/minitest/helpers.rb +16 -11
- data/lib/karafka/testing/rspec/helpers.rb +0 -3
- data/lib/karafka/testing/version.rb +1 -1
- data/lib/karafka/testing.rb +0 -27
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4932859009198b689571ee03c117e5255efbba52deb34874c689577cd456bf47
|
4
|
+
data.tar.gz: a83d1892a15392beb4889d77f642c2368b9a57a07073e9ce6ae4f884ad6ba61c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c99a0ece8c0ae1e2b46541148236b86ce26f1652c6e3cd82e4d3158ed42797b67019a4ec79db3c21efbc9a8e65e53e7e07cc6effa876190b5377dbd1cf2a8f2
|
7
|
+
data.tar.gz: d422ab991a2cfa2796e8dff02d9902c19f3d64e8f6d4d269283468abfbb0c20569f699faeef4f78dac440662ab94fea7da293361a7f824ba5219070358e6c1fa
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Karafka Test gem changelog
|
2
2
|
|
3
|
+
## 2.3.2 (2024-04-03)
|
4
|
+
- [Enhancement] Support `Minitest::Spec`.
|
5
|
+
|
3
6
|
## 2.3.1 (2024-03-07)
|
4
7
|
- [Enhancement] Prevent usage of testing when Karafka is not loaded.
|
5
8
|
- [Enhancement] Prevent usage of testing when Karafka is not initialized.
|
data/Gemfile.lock
CHANGED
@@ -15,17 +15,7 @@ module Karafka
|
|
15
15
|
TopicInManyConsumerGroupsError = Class.new(BaseError)
|
16
16
|
|
17
17
|
# Raised when you requested a topic from a consumer group that does not exist
|
18
|
-
|
19
|
-
|
20
|
-
# Raised when trying to use testing without Karafka app being visible
|
21
|
-
# If you are seeing this error, then you tried to use testing helpers without Karafka being
|
22
|
-
# loaded prior to this happening.
|
23
|
-
KarafkaNotLoadedError = Class.new(BaseError)
|
24
|
-
|
25
|
-
# Raised when there is an attempt to use the testing primitives without Karafka app being
|
26
|
-
# configured. Prior to initialization process, most of config values are nils, etc and
|
27
|
-
# mocks will not work.
|
28
|
-
KarafkaNotInitializedError = Class.new(BaseError)
|
18
|
+
ConsumerGroupNotFound = Class.new(BaseError)
|
29
19
|
end
|
30
20
|
end
|
31
21
|
end
|
@@ -16,19 +16,25 @@ module Karafka
|
|
16
16
|
# Adds all the needed extra functionalities to the minitest group
|
17
17
|
# @param base [Class] Minitest example group we want to extend
|
18
18
|
def included(base)
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
eval_flow = lambda do
|
20
|
+
@karafka = Karafka::Testing::Minitest::Proxy.new(self)
|
21
|
+
@_karafka_consumer_messages = []
|
22
|
+
@_karafka_consumer_client = Karafka::Testing::SpecConsumerClient.new
|
23
|
+
@_karafka_producer_client = Karafka::Testing::SpecProducerClient.new(self)
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
@_karafka_consumer_client = Karafka::Testing::SpecConsumerClient.new
|
26
|
-
@_karafka_producer_client = Karafka::Testing::SpecProducerClient.new(self)
|
25
|
+
@_karafka_consumer_messages.clear
|
26
|
+
@_karafka_producer_client.reset
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
Karafka.producer.stubs(:client).returns(@_karafka_producer_client)
|
29
|
+
end
|
30
30
|
|
31
|
-
|
31
|
+
if base.to_s == 'Minitest::Spec'
|
32
|
+
base.class_eval do
|
33
|
+
before(&eval_flow)
|
34
|
+
end
|
35
|
+
else
|
36
|
+
base.class_eval do
|
37
|
+
setup(&eval_flow)
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
@@ -178,7 +184,6 @@ module Karafka
|
|
178
184
|
rescue Karafka::Errors::TopicNotFoundError
|
179
185
|
nil
|
180
186
|
end
|
181
|
-
.uniq(&:consumer_group)
|
182
187
|
end
|
183
188
|
|
184
189
|
# Finds subscription groups from the requested consumer group or selects all if no
|
@@ -30,8 +30,6 @@ module Karafka
|
|
30
30
|
base.let(:_karafka_producer_client) { Karafka::Testing::SpecProducerClient.new(self) }
|
31
31
|
|
32
32
|
base.prepend_before do
|
33
|
-
Karafka::Testing.ensure_karafka_initialized!
|
34
|
-
|
35
33
|
_karafka_consumer_messages.clear
|
36
34
|
_karafka_producer_client.reset
|
37
35
|
|
@@ -196,7 +194,6 @@ module Karafka
|
|
196
194
|
rescue Karafka::Errors::TopicNotFoundError
|
197
195
|
nil
|
198
196
|
end
|
199
|
-
.uniq(&:consumer_group)
|
200
197
|
end
|
201
198
|
|
202
199
|
# Finds subscription groups from the requested consumer group or selects all if no
|
data/lib/karafka/testing.rb
CHANGED
@@ -4,32 +4,5 @@
|
|
4
4
|
module Karafka
|
5
5
|
# Testing lib module
|
6
6
|
module Testing
|
7
|
-
class << self
|
8
|
-
# Makes sure, that we do not use the testing stubs, etc when Karafka app is not loaded
|
9
|
-
#
|
10
|
-
# You should never use karafka-testing primitives when framework is not loaded because
|
11
|
-
# testing lib stubs certain pieces of Karafka that need to be initialized.
|
12
|
-
def ensure_karafka_loaded!
|
13
|
-
return if ::Karafka.const_defined?('App', false)
|
14
|
-
|
15
|
-
raise(
|
16
|
-
Karafka::Testing::Errors::KarafkaNotLoadedError,
|
17
|
-
'Make sure to load Karafka framework prior to usage of the testing components.'
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
|
-
# If you do not initialize Karafka always within your specs, do not include/use this lib
|
22
|
-
# in places where Karafka would not be loaded.
|
23
|
-
def ensure_karafka_initialized!
|
24
|
-
ensure_karafka_loaded!
|
25
|
-
|
26
|
-
return unless Karafka::App.initializing?
|
27
|
-
|
28
|
-
raise(
|
29
|
-
Karafka::Testing::Errors::KarafkaNotInitializedError,
|
30
|
-
'Make sure to initialize Karafka framework prior to usage of the testing components.'
|
31
|
-
)
|
32
|
-
end
|
33
|
-
end
|
34
7
|
end
|
35
8
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karafka-testing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Mensfeld
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
AnG1dJU+yL2BK7vaVytLTstJME5mepSZ46qqIJXMuWob/YPDmVaBF39TDSG9e34s
|
36
36
|
msG3BiCqgOgHAnL23+CN3Rt8MsuRfEtoTKpJVcCfoEoNHOkc
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2024-
|
38
|
+
date: 2024-04-11 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: karafka
|
metadata.gz.sig
CHANGED
Binary file
|