Class: Sbmt::Pact::Provider::BaseVerifier
- Inherits:
-
Object
- Object
- Sbmt::Pact::Provider::BaseVerifier
- Defined in:
- lib/sbmt/pact/provider/base_verifier.rb
Direct Known Subclasses
Defined Under Namespace
Classes: VerificationError, VerifierError
Constant Summary collapse
- PROVIDER_TRANSPORT_TYPE =
nil
- DEFAULT_CONSUMER_SELECTORS =
{"deployed" => true, "environment" => "production"}.freeze
- VERIFICATION_ERRORS =
{ 1 => {reason: :verification_failed, status: 1, description: "The verification process failed, see output for errors"}, 2 => {reason: :null_pointer, status: 2, description: "A null pointer was received"}, 3 => {reason: :internal_error, status: 3, description: "The method panicked"}, 4 => {reason: :invalid_arguments, status: 4, description: "Invalid arguments were provided to the verification process"} }.freeze
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(pact_config) ⇒ BaseVerifier
constructor
env below are set up by pipeline-builder see paas/cicd/images/pact/pipeline-builder/-/blob/master/internal/commands/consumers-pipeline/ruby.go.
- #verify! ⇒ Object
Constructor Details
#initialize(pact_config) ⇒ BaseVerifier
env below are set up by pipeline-builder see paas/cicd/images/pact/pipeline-builder/-/blob/master/internal/commands/consumers-pipeline/ruby.go
30 31 32 33 34 |
# File 'lib/sbmt/pact/provider/base_verifier.rb', line 30 def initialize(pact_config) raise ArgumentError, "pact_config must be a subclass of Sbmt::Pact::Provider::PactConfig::Base" unless pact_config.is_a?(::Sbmt::Pact::Provider::PactConfig::Base) @pact_config = pact_config @logger = Logger.new($stdout) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/sbmt/pact/provider/base_verifier.rb', line 12 def logger @logger end |
Instance Method Details
#verify! ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/sbmt/pact/provider/base_verifier.rb', line 36 def verify! raise VerifierError.new("interaction is designed to be used one-time only") if defined?(@used) if consumer_selectors.blank? logger.info("[verifier] does not need to verify consumer #{@pact_config.consumer_name}") return end exception = nil pact_handle = init_pact start_servers! logger.info("[verifier] starting provider verification") result = Sbmt::Pact::Native::BlockingVerifier.execute(pact_handle) if VERIFICATION_ERRORS[result].present? error = VERIFICATION_ERRORS[result] exception = VerificationError.new("There was an error while trying to verify provider \"#{@pact_config.provider_name}\"", error[:reason], error[:status]) end ensure @used = true PactFfi::Verifier.shutdown(pact_handle) if pact_handle stop_servers raise exception if exception end |