File tree 5 files changed +35
-2
lines changed
5 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ def to_json(options)
17
17
18
18
def to_hash ( options )
19
19
{
20
+ summary : {
21
+ compatible : compatible?
22
+ } ,
20
23
matrix : matrix ( lines , options [ :user_options ] [ :base_url ] )
21
24
}
22
25
end
@@ -25,6 +28,10 @@ def to_hash(options)
25
28
26
29
attr_reader :lines
27
30
31
+ def compatible?
32
+ lines . any? && lines . all? { |line | line [ :success ] }
33
+ end
34
+
28
35
def matrix ( lines , base_url )
29
36
provider = nil
30
37
consumer = nil
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def malformed_request?
27
27
28
28
def to_json
29
29
criteria = selected_versions . each_with_object ( { } ) { | version , hash | hash [ version . pacticipant . name ] = version . number }
30
- lines = matrix_service . find_compatible_pacticipant_versions ( criteria )
30
+ lines = matrix_service . find ( criteria )
31
31
PactBroker ::Api ::Decorators ::MatrixPactDecorator . new ( lines ) . to_json ( user_options : { base_url : base_url } )
32
32
end
33
33
Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ module Service
9
9
extend PactBroker ::Repositories
10
10
extend PactBroker ::Services
11
11
12
+ def find criteria
13
+ matrix_repository . find criteria
14
+ end
15
+
12
16
def find_for_consumer_and_provider params
13
17
matrix_repository . find_for_consumer_and_provider params [ :consumer_name ] , params [ :provider_name ]
14
18
end
@@ -43,6 +47,10 @@ def validate_selectors selectors
43
47
end
44
48
end
45
49
50
+ if selectors . size < 2
51
+ error_messages << "Please provide 2 or more version selectors."
52
+ end
53
+
46
54
error_messages
47
55
end
48
56
end
Original file line number Diff line number Diff line change @@ -113,6 +113,10 @@ module Decorators
113
113
expect ( parsed_json [ :matrix ] [ 0 ] [ :pact ] ) . to eq pact_hash
114
114
end
115
115
116
+ it "includes a summary" do
117
+ expect ( parsed_json [ :summary ] [ :compatible ] ) . to eq false
118
+ end
119
+
116
120
context "when the pact has not been verified" do
117
121
let ( :verification_hash ) do
118
122
nil
Original file line number Diff line number Diff line change 3
3
module PactBroker
4
4
module Matrix
5
5
describe Service do
6
+ let ( :td ) { TestDataBuilder . new }
7
+
6
8
describe "validate_selectors" do
7
- let ( :td ) { TestDataBuilder . new }
8
9
9
10
subject { Service . validate_selectors ( selectors ) }
10
11
@@ -16,6 +17,19 @@ module Matrix
16
17
end
17
18
end
18
19
20
+ context "when there is only one selector" do
21
+ before do
22
+ td . create_pacticipant ( "Foo" )
23
+ . create_version ( "1" )
24
+ end
25
+
26
+ let ( :selectors ) { [ "Foo/version/1" ] }
27
+
28
+ it "returns error messages" do
29
+ expect ( subject . first ) . to eq "Please provide 2 or more version selectors."
30
+ end
31
+ end
32
+
19
33
context "when one or more of the selectors does not match any known version" do
20
34
before do
21
35
td . create_pacticipant ( "Foo" )
You can’t perform that action at this time.
0 commit comments