Skip to content

Commit

Permalink
fix(publish-provider-contract): raise validation error when pact brok…
Browse files Browse the repository at this point in the history
…er base URL is missing or blank
  • Loading branch information
bethesque committed Jun 24, 2022
1 parent 037736c commit 2d719c3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/pactflow/client/cli/provider_contract_commands.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
require "pact_broker/client/hash_refinements"
require "pact_broker/client/string_refinements"

module Pactflow
module Client
module CLI
module ProviderContractCommands
using PactBroker::Client::HashRefinements
using PactBroker::Client::StringRefinements

def self.included(thor)
thor.class_eval do
Expand Down Expand Up @@ -32,6 +34,7 @@ def self.included(thor)
def publish_provider_contract(provider_contract_path)
require "pactflow/client/provider_contracts/publish"

validate_pact_broker_url
validate_publish_provider_contract_options(provider_contract_path)
result = ::Pactflow::Client::ProviderContracts::Publish.call(
publish_provider_contract_command_params(provider_contract_path),
Expand All @@ -47,6 +50,12 @@ def command_options
{ verbose: options.verbose, output: options.output }
end

def validate_pact_broker_url
if pact_broker_client_options[:pact_broker_base_url].blank?
raise Thor::Error, "No value provided for required option --broker-base-url or environment variable PACT_BROKER_BASE_URL"
end
end

def validate_publish_provider_contract_options(provider_contract_path)
if !options.verification_success.nil? && options.verification_exit_code
raise Thor::Error, "Cannot use both --verification-success|--no-verification-success and --verification-exit-code"
Expand Down

0 comments on commit 2d719c3

Please sign in to comment.