Skip to content

Commit

Permalink
feat(matrix): improve reason when no results are found
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Nov 6, 2017
1 parent a6a8ba2 commit 473abbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/pact_broker/api/decorators/matrix_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ def to_hash(options)
end

def deployable
return nil if lines.empty?
return nil if lines.any?{ |line| line[:success].nil? }
lines.any? && lines.all?{ |line| line[:success] }
end

def reason
return "No results matched the given query" if lines.empty?
case deployable
when true then "All verification results are published and successful"
when false then "One or more verifications have failed"
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/pact_broker/api/decorators/matrix_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ module Decorators
expect(parsed_json[:summary][:reason]).to match /have failed/
end
end

context "when there are no results" do
let(:lines) { [] }

it "has a deployable flag of false" do
expect(parsed_json[:summary][:deployable]).to be nil
end

it "has an explanation" do
expect(parsed_json[:summary][:reason]).to match /No results/
end
end
end
end
end
Expand Down

0 comments on commit 473abbe

Please sign in to comment.