Skip to content

Commit 473abbe

Browse files
committed
feat(matrix): improve reason when no results are found
1 parent a6a8ba2 commit 473abbe

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/pact_broker/api/decorators/matrix_decorator.rb

+2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ def to_hash(options)
2626
end
2727

2828
def deployable
29+
return nil if lines.empty?
2930
return nil if lines.any?{ |line| line[:success].nil? }
3031
lines.any? && lines.all?{ |line| line[:success] }
3132
end
3233

3334
def reason
35+
return "No results matched the given query" if lines.empty?
3436
case deployable
3537
when true then "All verification results are published and successful"
3638
when false then "One or more verifications have failed"

spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ module Decorators
160160
expect(parsed_json[:summary][:reason]).to match /have failed/
161161
end
162162
end
163+
164+
context "when there are no results" do
165+
let(:lines) { [] }
166+
167+
it "has a deployable flag of false" do
168+
expect(parsed_json[:summary][:deployable]).to be nil
169+
end
170+
171+
it "has an explanation" do
172+
expect(parsed_json[:summary][:reason]).to match /No results/
173+
end
174+
end
163175
end
164176
end
165177
end

0 commit comments

Comments
 (0)