pact-mock_service 3.2.1 → 3.3.0

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: 8f5c4344c8cd4ad35c428bba1596877909fc81cfda1eaae0a71e80521d3129f2
4
- data.tar.gz: 436534d7b43f1f60917c050abae962104dcc9650b6eb2d3df55e3dbc73509b44
3
+ metadata.gz: 70978afac2d8baa00d8723c1852b88652bb9988498adc9ea1077aa6f11a0e5d1
4
+ data.tar.gz: 2d328532b86c3b2deb265b26770a6c2b72282e3d6fd4fdfeff6237fe0f1a965d
5
5
  SHA512:
6
- metadata.gz: c45bb5349e99a7ae0b51ec8e281491f5c8075686d5bf91aa4d4ea89646fee9948339fdccab42d3fb01234cf83aa2241faf8d4c301f533fc9c70b6c9f4210c430
7
- data.tar.gz: 3eab8a731f151768b7fc7bab4f7002ec947a0f38c59aca9bef54a856cf4535a5de2ec665aef8b54c9cae966f6cfdfa78e7319770d09e28e82cbf738612654949
6
+ metadata.gz: 4621e740a4d865554ab7186547275b079955277d0c1883f31cde9c5932e56b1f3f17226edb8cd82738790b81c86cae28070f3c636c2041357a125915af55ec8e
7
+ data.tar.gz: bb71b263fd9663676f90a58f8b5198f7bebcc346677151269eba80c9c5d0a3a4bc8bf9d434d4a354e09c57515c4233ef6ee467e5126c35a3b59ecb1d31ccbd9a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ <a name="v3.3.0"></a>
2
+ ### v3.3.0 (2020-01-16)
3
+
4
+
5
+ #### Features
6
+
7
+ * log a warning when too many interactions are set on the mock service at once ([0ce6bef](/../../commit/0ce6bef))
8
+
9
+
1
10
  <a name="v3.2.1"></a>
2
11
  ### v3.2.1 (2020-01-11)
3
12
 
@@ -15,12 +15,12 @@ module Pact
15
15
  end
16
16
 
17
17
  class App
18
-
19
18
  def initialize options = {}
20
19
  logger = Logger.from_options(options)
20
+ stubbing = options[:stub_pactfile_paths] && options[:stub_pactfile_paths].any?
21
21
  @name = options.fetch(:name, "MockService")
22
- @session = Session.new(options.merge(logger: logger))
23
- setup_stub(options[:stub_pactfile_paths]) if options[:stub_pactfile_paths]
22
+ @session = Session.new(options.merge(logger: logger, warn_on_too_many_interactions: !stubbing))
23
+ setup_stub(options[:stub_pactfile_paths]) if stubbing
24
24
  request_handlers = RequestHandlers.new(@name, logger, @session, options)
25
25
  @app = Rack::Builder.app do
26
26
  use Pact::Consumer::MockService::ErrorHandler, logger
@@ -17,6 +17,8 @@ module Pact
17
17
  @expected_interactions = Interactions::ExpectedInteractions.new
18
18
  @actual_interactions = Interactions::ActualInteractions.new
19
19
  @verified_interactions = Interactions::VerifiedInteractions.new
20
+ @warn_on_too_many_interactions = options[:warn_on_too_many_interactions] || false
21
+ @max_concurrent_interactions_before_warning = get_max_concurrent_interactions_before_warning
20
22
  @consumer_contract_details = {
21
23
  pact_dir: options[:pact_dir],
22
24
  consumer: {name: options[:consumer]},
@@ -64,10 +66,15 @@ module Pact
64
66
 
65
67
  private
66
68
 
69
+ attr_reader :warn_on_too_many_interactions, :max_concurrent_interactions_before_warning
70
+
67
71
  def really_add_expected_interaction interaction
68
72
  expected_interactions << interaction
69
73
  logger.info "Registered expected interaction #{interaction.request.method_and_path}"
70
74
  logger.debug JSON.pretty_generate InteractionDecorator.new(interaction)
75
+ if warn_on_too_many_interactions && expected_interactions.size > max_concurrent_interactions_before_warning
76
+ logger.warn "You currently have #{expected_interactions.size} interactions mocked at the same time. This suggests the scope of your consumer tests is larger than recommended, and you may find them hard to debug and maintain. See https://pact.io/too-many-interactions for more information."
77
+ end
71
78
  end
72
79
 
73
80
  def handle_almost_duplicate_interaction previous_interaction, interaction
@@ -81,6 +88,9 @@ module Pact
81
88
  other && other != interaction ? other : nil
82
89
  end
83
90
 
91
+ def get_max_concurrent_interactions_before_warning
92
+ ENV['PACT_MAX_CONCURRENT_INTERACTIONS_BEFORE_WARNING'] ? ENV['PACT_MAX_CONCURRENT_INTERACTIONS_BEFORE_WARNING'].to_i : 3
93
+ end
84
94
  end
85
95
  end
86
96
  end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module MockService
3
- VERSION = "3.2.1"
3
+ VERSION = "3.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-mock_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-01-11 00:00:00.000000000 Z
15
+ date: 2020-01-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rack