From 3e39517f1f41b74684fc8011e8f8ddac46117026 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 11 Aug 2017 14:27:31 +1000 Subject: [PATCH] feat(run single interaction): allow env vars to be set to run a single interaction Set PACT_DESCRIPTION and PACT_PROVIDER_STATE to run a specific interaction instead of the full pact --- lib/pact/provider_verifier/app.rb | 3 +++ spec/integration_spec.rb | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/pact/provider_verifier/app.rb b/lib/pact/provider_verifier/app.rb index 7072be6..e9e9ca0 100644 --- a/lib/pact/provider_verifier/app.rb +++ b/lib/pact/provider_verifier/app.rb @@ -94,6 +94,9 @@ def verify_pact pact_url :pact_broker_username => @options.broker_username, :pact_broker_password => @options.broker_password } + options[:description] = ENV['PACT_DESCRIPTION'] if ENV['PACT_DESCRIPTION'] + options[:provider_state] = ENV['PACT_PROVIDER_STATE'] if ENV['PACT_PROVIDER_STATE'] + Cli::RunPactVerification.call(options) rescue SystemExit => e puts "" diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index 89336f9..c4019f1 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -18,7 +18,7 @@ end end - context "with two passing pacts" do + context "with two passing interactions" do subject { `bundle exec bin/pact-provider-verifier -a 1.0.100 --provider-base-url http://localhost:4567 --pact-urls ./test/me-they.json,./test/another-they.json --provider_states_setup_url http://localhost:4567/provider-state -v` } it "exits with a 0 exit code" do @@ -58,6 +58,20 @@ end end + context "running verification with filtered interactions" do + + subject { `PACT_DESCRIPTION="Provider state success" PACT_PROVIDER_STATE="There is a greeting" bundle exec bin/pact-provider-verifier -a 1.0.100 --provider-base-url http://localhost:4567 --pact-urls ./test/me-they.json --provider_states_setup_url http://localhost:4567/provider-state -v` } + + it "exits with a 0 exit code" do + subject + expect($?).to eq 0 + end + + it "the output contains a message indicating that the interactions have been filtered" do + expect(subject).to match /Filtering interactions by.*Provider state success.*There is a greeting/ + end + end + after(:all) do Process.kill 'KILL', @pipe.pid