karafka-testing 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7234ba09684afa8617cf8c3f335462e418dbe1369792949d189029f9ec22e40c
4
- data.tar.gz: '0861af20657686d3f7b3b0f99453959df567eb2b91f5ba1e60c23416e272633a'
3
+ metadata.gz: 5b5e94cc98b3418a25cd549e4e9f4851d22fa819b499b77185afb7ee1e1f10c6
4
+ data.tar.gz: 415e32601301d2f07de6c575109c443af8f489c178041e387d6fe1d1530550ca
5
5
  SHA512:
6
- metadata.gz: a210c2545d78aa92c4b9fd554f7d9687268d39e9ccd86ca5ebe8f94de55a295226e5c10126e948b11a769695baecbfaee183aa2318a1ce9a3e8aa4f0e8136791
7
- data.tar.gz: 1f6365ee9adec3023b077c073c74ed10e66271d00ebd656eeb54bc12f912a981583f3e10e113bff530fa3a4dc3994ee95d4b95e93347f7576d6efa186ee0ff7b
6
+ metadata.gz: 17eb73114b43f84c813ad176f8a8913fde8f175f0b41ecbe78bfd3bb20c30259aaab791cd9cb719c1aab9cef0daceed651d7c342201fffd227db495f5d55ce51
7
+ data.tar.gz: e42445092d3ab33eb27d1145c9897f94b3758bd57b624935fd8d8fd3f37999d3333caf70b2c713196a672978b478a8dc4a5923aa6924387331c076334e14391f
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Karafka Test gem changelog
2
2
 
3
+ ## 2.3.1 (2024-03-07)
4
+ - [Enhancement] Prevent usage of testing when Karafka is not loaded.
5
+ - [Enhancement] Prevent usage of testing when Karafka is not initialized.
6
+ - [Fix] Same CG multiplexing topic builder fails with `TopicInManyConsumerGroupsError`.
7
+
3
8
  ## 2.3.0 (2024-01-26)
4
9
  - [Maintenance] Release matching Karafka `2.3.0` release.
5
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-testing (2.3.0)
4
+ karafka-testing (2.3.1)
5
5
  karafka (>= 2.3.0, < 2.4.0)
6
6
  waterdrop (>= 2.6.12)
7
7
 
@@ -9,22 +9,22 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  ffi (1.16.3)
12
- karafka (2.3.0)
12
+ karafka (2.3.3)
13
13
  karafka-core (>= 2.3.0, < 2.4.0)
14
14
  waterdrop (>= 2.6.12, < 3.0.0)
15
15
  zeitwerk (~> 2.3)
16
16
  karafka-core (2.3.0)
17
17
  karafka-rdkafka (>= 0.14.8, < 0.15.0)
18
- karafka-rdkafka (0.14.8)
18
+ karafka-rdkafka (0.14.10)
19
19
  ffi (~> 1.15)
20
20
  mini_portile2 (~> 2.6)
21
21
  rake (> 12)
22
22
  mini_portile2 (2.8.5)
23
23
  rake (13.1.0)
24
- waterdrop (2.6.12)
24
+ waterdrop (2.6.14)
25
25
  karafka-core (>= 2.2.3, < 3.0.0)
26
26
  zeitwerk (~> 2.3)
27
- zeitwerk (2.6.12)
27
+ zeitwerk (2.6.13)
28
28
 
29
29
  PLATFORMS
30
30
  ruby
@@ -34,4 +34,4 @@ DEPENDENCIES
34
34
  karafka-testing!
35
35
 
36
36
  BUNDLED WITH
37
- 2.5.5
37
+ 2.5.6
@@ -15,7 +15,17 @@ 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
- ConsumerGroupNotFound = Class.new(BaseError)
18
+ ConsumerGroupNotFoundError = Class.new(BaseError)
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)
19
29
  end
20
30
  end
21
31
  end
@@ -18,6 +18,8 @@ module Karafka
18
18
  def included(base)
19
19
  base.class_eval do
20
20
  setup do
21
+ Karafka::Testing.ensure_karafka_initialized!
22
+
21
23
  @karafka = Karafka::Testing::Minitest::Proxy.new(self)
22
24
  @_karafka_consumer_messages = []
23
25
  @_karafka_consumer_client = Karafka::Testing::SpecConsumerClient.new
@@ -176,6 +178,7 @@ module Karafka
176
178
  rescue Karafka::Errors::TopicNotFoundError
177
179
  nil
178
180
  end
181
+ .uniq(&:consumer_group)
179
182
  end
180
183
 
181
184
  # Finds subscription groups from the requested consumer group or selects all if no
@@ -30,6 +30,8 @@ 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
+
33
35
  _karafka_consumer_messages.clear
34
36
  _karafka_producer_client.reset
35
37
 
@@ -194,6 +196,7 @@ module Karafka
194
196
  rescue Karafka::Errors::TopicNotFoundError
195
197
  nil
196
198
  end
199
+ .uniq(&:consumer_group)
197
200
  end
198
201
 
199
202
  # Finds subscription groups from the requested consumer group or selects all if no
@@ -4,6 +4,6 @@
4
4
  module Karafka
5
5
  module Testing
6
6
  # Current version of gem. It should match Karafka framework version
7
- VERSION = '2.3.0'
7
+ VERSION = '2.3.1'
8
8
  end
9
9
  end
@@ -4,5 +4,32 @@
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
7
34
  end
8
35
  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.0
4
+ version: 2.3.1
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-01-26 00:00:00.000000000 Z
38
+ date: 2024-03-07 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka
metadata.gz.sig CHANGED
Binary file