Skip to content

Commit

Permalink
feat: enable publishing provider contracts using the 'all in one' end…
Browse files Browse the repository at this point in the history
…point

Remove feature toggle.
  • Loading branch information
bethesque committed Sep 11, 2023
1 parent d99e09d commit 398d58c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/pactflow/client/provider_contracts/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ def initialize(params, options, pact_broker_client_options)
attr_reader :provider_name, :provider_version_number, :branch_name, :tags, :build_url, :contract, :verification_results

def do_call
if enabled? && index_resource.assert_success!.can?(PUBLISH_RELATION)
if !disabled? && index_resource.assert_success!.can?(PUBLISH_RELATION)
publish_provider_contracts
PactBroker::Client::CommandResult.new(success?, message)
else
PublishTheOldWay.call(params, options, pact_broker_client_options)
end
end

def enabled?
ENV.fetch("PACT_BROKER_FEATURES", "").include?("publish_provider_contracts_all_in_one")
def disabled?
ENV.fetch("PACTFLOW_FEATURES", "").include?("publish_provider_contracts_using_old_api")
end

def publish_provider_contracts
Expand Down
4 changes: 0 additions & 4 deletions spec/integration/publish_provider_contract_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
require "pactflow/client/cli/pactflow"

RSpec.describe "publish-provider-contract" do
before do
allow(ENV).to receive(:fetch).and_call_original
allow(ENV).to receive(:fetch).with("PACT_BROKER_FEATURES", "").and_return("publish_provider_contracts_all_in_one")
end
let(:index_body_hash) do
{
_links: {
Expand Down
7 changes: 3 additions & 4 deletions spec/lib/pactflow/client/provider_contracts/publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module ProviderContracts
before do
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
allow(ENV).to receive(:fetch).and_call_original
allow(ENV).to receive(:fetch).with("PACT_BROKER_FEATURES", "").and_return("publish_provider_contracts_all_in_one")
end

let(:command_params) do
Expand Down Expand Up @@ -99,9 +97,10 @@ module ProviderContracts
end
end

context "when the feature is not enabled" do
context "when the feature is disabled" do
before do
allow(ENV).to receive(:fetch).with("PACT_BROKER_FEATURES", "").and_return("")
allow(ENV).to receive(:fetch).and_call_original
allow(ENV).to receive(:fetch).with("PACTFLOW_FEATURES", "").and_return("publish_provider_contracts_using_old_api")
end

it "publishes the provider contracts the old way" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
before do
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:sleep)
allow_any_instance_of(PactBroker::Client::Hal::HttpClient).to receive(:default_max_tries).and_return(1)
allow(ENV).to receive(:fetch).and_call_original
allow(ENV).to receive(:fetch).with("PACT_BROKER_FEATURES", "").and_return("publish_provider_contracts_all_in_one")
end

include_context "pact broker"
Expand Down

0 comments on commit 398d58c

Please sign in to comment.