karafka-testing 2.3.2 → 2.4.0.beta1

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: 4932859009198b689571ee03c117e5255efbba52deb34874c689577cd456bf47
4
- data.tar.gz: a83d1892a15392beb4889d77f642c2368b9a57a07073e9ce6ae4f884ad6ba61c
3
+ metadata.gz: e62624d40d7aa454841a212de1beaf67127ef06873bd0604dcbfe4747a397cf5
4
+ data.tar.gz: 2e031857e92ce50f55ea24e3cb32309a070c11ea930de263f05ec9c82f24992d
5
5
  SHA512:
6
- metadata.gz: 0c99a0ece8c0ae1e2b46541148236b86ce26f1652c6e3cd82e4d3158ed42797b67019a4ec79db3c21efbc9a8e65e53e7e07cc6effa876190b5377dbd1cf2a8f2
7
- data.tar.gz: d422ab991a2cfa2796e8dff02d9902c19f3d64e8f6d4d269283468abfbb0c20569f699faeef4f78dac440662ab94fea7da293361a7f824ba5219070358e6c1fa
6
+ metadata.gz: b2c5398aa8d03a31499a29b60f3e45456e6151cbbd57f979dac9ddc6aea283e5fb6b0613a1df336fb3d46284af16861125a7df980c9701ace2af2d2d3ef8336f
7
+ data.tar.gz: f32201af31b9e0840ce41e7c17a16a64b7fedfb99a4cb1815f2b18a1fa45bed474eb9dc02e3b68e504a0d2be2191a141e64ed52fad25fee9ba86e42030250a0f
checksums.yaml.gz.sig CHANGED
Binary file
@@ -22,7 +22,6 @@ jobs:
22
22
  - '3.2'
23
23
  - '3.1'
24
24
  - '3.0'
25
- - '2.7'
26
25
  include:
27
26
  - ruby: '3.3'
28
27
  coverage: 'true'
@@ -40,24 +39,14 @@ jobs:
40
39
 
41
40
  - name: Install latest bundler
42
41
  run: |
43
- if [[ "$(ruby -v | awk '{print $2}')" == 2.7.8* ]]; then
44
- gem install bundler -v 2.4.22 --no-document
45
- bundle config set version 2.4.22
46
- gem update --system 3.4.22 --no-document
47
- else
48
- gem install bundler --no-document
49
- gem update --system --no-document
50
- fi
42
+ gem install bundler --no-document
43
+ gem update --system --no-document
51
44
 
52
45
  bundle config set without 'tools benchmarks docs'
53
46
 
54
47
  - name: Bundle install
55
48
  run: |
56
- if [[ "$(ruby -v | awk '{print $2}')" == 2.7.8* ]]; then
57
- BUNDLER_VERSION=2.4.22 bundle install --jobs 4 --retry 3
58
- else
59
- bundle install --jobs 4 --retry 3
60
- fi
49
+ bundle install --jobs 4 --retry 3
61
50
 
62
51
  diffend:
63
52
  runs-on: ubuntu-latest
data/CHANGELOG.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Karafka Test gem changelog
2
2
 
3
- ## 2.3.2 (2024-04-03)
4
- - [Enhancement] Support `Minitest::Spec`.
3
+ ## 2.4.0 (Unreleased)
4
+ - **[Breaking]** Drop Ruby `2.7` support.
5
+ - [Fix] Support again `require: false` on gem loading.
5
6
 
6
7
  ## 2.3.1 (2024-03-07)
7
8
  - [Enhancement] Prevent usage of testing when Karafka is not loaded.
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- karafka-testing (2.3.2)
5
- karafka (>= 2.3.0, < 2.4.0)
6
- waterdrop (>= 2.6.12)
4
+ karafka-testing (2.4.0.beta1)
5
+ karafka (>= 2.3.0, < 2.5.0)
6
+ waterdrop (>= 2.7.0.beta2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -13,16 +13,16 @@ GEM
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
- karafka-core (2.3.0)
17
- karafka-rdkafka (>= 0.14.8, < 0.15.0)
18
- karafka-rdkafka (0.14.10)
16
+ karafka-core (2.4.0.beta2)
17
+ karafka-rdkafka (>= 0.15.0.beta3, < 0.16.0)
18
+ karafka-rdkafka (0.15.0.beta3)
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.14)
25
- karafka-core (>= 2.2.3, < 3.0.0)
24
+ waterdrop (2.7.0.beta2)
25
+ karafka-core (>= 2.4.0.beta2, < 3.0.0)
26
26
  zeitwerk (~> 2.3)
27
27
  zeitwerk (2.6.13)
28
28
 
@@ -24,8 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
25
25
  end
26
26
 
27
- spec.add_dependency 'karafka', '>= 2.3.0', '< 2.4.0'
28
- spec.add_dependency 'waterdrop', '>= 2.6.12'
27
+ spec.add_dependency 'karafka', '>= 2.3.0', '< 2.5.0'
28
+ spec.add_dependency 'waterdrop', '>= 2.7.0.beta2'
29
+
30
+ spec.required_ruby_version = '>= 3.0.0'
29
31
 
30
32
  spec.metadata = {
31
33
  'funding_uri' => 'https://karafka.io/#become-pro',
@@ -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
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'karafka/testing'
3
4
  require 'karafka/testing/errors'
4
5
  require 'karafka/testing/spec_consumer_client'
5
6
  require 'karafka/testing/spec_producer_client'
@@ -16,25 +17,19 @@ module Karafka
16
17
  # Adds all the needed extra functionalities to the minitest group
17
18
  # @param base [Class] Minitest example group we want to extend
18
19
  def included(base)
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)
20
+ base.class_eval do
21
+ setup do
22
+ Karafka::Testing.ensure_karafka_initialized!
24
23
 
25
- @_karafka_consumer_messages.clear
26
- @_karafka_producer_client.reset
24
+ @karafka = Karafka::Testing::Minitest::Proxy.new(self)
25
+ @_karafka_consumer_messages = []
26
+ @_karafka_consumer_client = Karafka::Testing::SpecConsumerClient.new
27
+ @_karafka_producer_client = Karafka::Testing::SpecProducerClient.new(self)
27
28
 
28
- Karafka.producer.stubs(:client).returns(@_karafka_producer_client)
29
- end
29
+ @_karafka_consumer_messages.clear
30
+ @_karafka_producer_client.reset
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
+ Karafka.producer.stubs(:client).returns(@_karafka_producer_client)
38
33
  end
39
34
  end
40
35
  end
@@ -135,10 +130,10 @@ module Karafka
135
130
  # @return [Hash] message default options
136
131
  def _karafka_message_metadata_defaults
137
132
  {
138
- deserializer: @consumer.topic.deserializer,
133
+ deserializers: @consumer.topic.deserializers,
139
134
  timestamp: Time.now,
140
- headers: {},
141
- key: nil,
135
+ raw_headers: {},
136
+ raw_key: nil,
142
137
  offset: @_karafka_consumer_messages.size,
143
138
  partition: 0,
144
139
  received_at: Time.now,
@@ -184,6 +179,7 @@ module Karafka
184
179
  rescue Karafka::Errors::TopicNotFoundError
185
180
  nil
186
181
  end
182
+ .uniq(&:consumer_group)
187
183
  end
188
184
 
189
185
  # Finds subscription groups from the requested consumer group or selects all if no
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'waterdrop'
4
+ require 'karafka/testing'
4
5
  require 'karafka/testing/errors'
5
6
  require 'karafka/testing/spec_consumer_client'
6
7
  require 'karafka/testing/spec_producer_client'
@@ -30,6 +31,8 @@ module Karafka
30
31
  base.let(:_karafka_producer_client) { Karafka::Testing::SpecProducerClient.new(self) }
31
32
 
32
33
  base.prepend_before do
34
+ Karafka::Testing.ensure_karafka_initialized!
35
+
33
36
  _karafka_consumer_messages.clear
34
37
  _karafka_producer_client.reset
35
38
 
@@ -144,10 +147,10 @@ module Karafka
144
147
  # @return [Hash] message default options
145
148
  def _karafka_message_metadata_defaults
146
149
  {
147
- deserializer: consumer.topic.deserializer,
150
+ deserializers: consumer.topic.deserializers,
148
151
  timestamp: Time.now,
149
- headers: {},
150
- key: nil,
152
+ raw_headers: {},
153
+ raw_key: nil,
151
154
  offset: _karafka_consumer_messages.size,
152
155
  partition: 0,
153
156
  received_at: Time.now,
@@ -194,6 +197,7 @@ module Karafka
194
197
  rescue Karafka::Errors::TopicNotFoundError
195
198
  nil
196
199
  end
200
+ .uniq(&:consumer_group)
197
201
  end
198
202
 
199
203
  # 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.2'
7
+ VERSION = '2.4.0.beta1'
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.2
4
+ version: 2.4.0.beta1
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-04-11 00:00:00.000000000 Z
38
+ date: 2024-03-27 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: karafka
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: 2.3.0
47
47
  - - "<"
48
48
  - !ruby/object:Gem::Version
49
- version: 2.4.0
49
+ version: 2.5.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,21 +56,21 @@ dependencies:
56
56
  version: 2.3.0
57
57
  - - "<"
58
58
  - !ruby/object:Gem::Version
59
- version: 2.4.0
59
+ version: 2.5.0
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: waterdrop
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 2.6.12
66
+ version: 2.7.0.beta2
67
67
  type: :runtime
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: 2.6.12
73
+ version: 2.7.0.beta2
74
74
  description: Library which provides helpers for easier Karafka consumers tests
75
75
  email:
76
76
  - contact@karafka.io
@@ -124,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - ">="
126
126
  - !ruby/object:Gem::Version
127
- version: '0'
127
+ version: 3.0.0
128
128
  required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
metadata.gz.sig CHANGED
Binary file