File tree 2 files changed +36
-1
lines changed
spec/lib/pact_broker/matrix
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -144,21 +144,23 @@ def look_up_version_numbers(selectors, options)
144
144
selectors . collect do | selector |
145
145
if selector [ :tag ] && selector [ :latest ]
146
146
version = version_repository . find_by_pacticipant_name_and_latest_tag ( selector [ :pacticipant_name ] , selector [ :tag ] )
147
- raise Error . new ( "Could not find version with tag #{ selector [ :tag ] . inspect } for #{ selector [ :pacticipant_name ] } " ) unless version
147
+ raise Error . new ( "No version of #{ selector [ :pacticipant_name ] } found with tag #{ selector [ :tag ] } " ) unless version
148
148
# validation in resource should ensure we always have a version
149
149
{
150
150
pacticipant_name : selector [ :pacticipant_name ] ,
151
151
pacticipant_version_number : version . number
152
152
}
153
153
elsif selector [ :latest ]
154
154
version = version_repository . find_latest_by_pacticpant_name ( selector [ :pacticipant_name ] )
155
+ raise Error . new ( "No version of #{ selector [ :pacticipant_name ] } found" ) unless version
155
156
{
156
157
pacticipant_name : selector [ :pacticipant_name ] ,
157
158
pacticipant_version_number : version . number
158
159
}
159
160
elsif selector [ :tag ]
160
161
# validation in resource should ensure we always have at least one version
161
162
versions = version_repository . find_by_pacticipant_name_and_tag ( selector [ :pacticipant_name ] , selector [ :tag ] )
163
+ raise Error . new ( "No version of #{ selector [ :pacticipant_name ] } found with tag #{ selector [ :tag ] } " ) unless versions . any?
162
164
versions . collect do | version |
163
165
{
164
166
pacticipant_name : selector [ :pacticipant_name ] ,
Original file line number Diff line number Diff line change @@ -964,6 +964,39 @@ def shorten_rows rows
964
964
expect ( subject . count ) . to eq 0
965
965
end
966
966
end
967
+
968
+ context "when there is no version for the specified tag" do
969
+ before do
970
+ TestDataBuilder . new
971
+ . create_pact_with_hierarchy ( "D" , "1" , "E" )
972
+ end
973
+
974
+ subject { Repository . new . find ( selectors ) }
975
+
976
+ context "when the latest tag is specified" do
977
+ let ( :selectors ) { [ { pacticipant_name : 'D' , latest : true , tag : 'dev' } ] }
978
+
979
+ it "raises an error" do
980
+ expect { subject } . to raise_error Error , /No version of D found/
981
+ end
982
+ end
983
+
984
+ context "when all tags are specified" do
985
+ let ( :selectors ) { [ { pacticipant_name : 'D' , tag : 'dev' } ] }
986
+
987
+ it "raises an error" do
988
+ expect { subject } . to raise_error Error , /No version of D found/
989
+ end
990
+ end
991
+
992
+ context "when no tags are specified" do
993
+ let ( :selectors ) { [ { pacticipant_name : 'E' , latest : true } ] }
994
+
995
+ it "raises an error" do
996
+ expect { subject } . to raise_error Error , /No version of E found/
997
+ end
998
+ end
999
+ end
967
1000
end
968
1001
end
969
1002
end
You can’t perform that action at this time.
0 commit comments