@@ -1033,6 +1033,57 @@ def with_web_server(path, **opts)
1033
1033
subject . call ( env )
1034
1034
end
1035
1035
1036
+ it "adds the latest version of a box with multiple providers and only one provider matching architecture" do
1037
+ box_path = iso_env . box2_file ( :virtualbox )
1038
+ tf = Tempfile . new ( [ "vagrant-box-latest-version" , ".json" ] ) . tap do |f |
1039
+ # NOTE: The order of the providers here matters. The correct match needs
1040
+ # to be last in order to trigger the error this test was written for to
1041
+ # catch any regression.
1042
+ f . write (
1043
+ {
1044
+ name : "foo/bar" ,
1045
+ versions : [
1046
+ {
1047
+ version : "0.5" ,
1048
+ } ,
1049
+ {
1050
+ version : "0.7" ,
1051
+ providers : [
1052
+ {
1053
+ name : "virtualbox" ,
1054
+ url : "/dev/null/invalid.path" ,
1055
+ architecture : "amd64" ,
1056
+ default_architecture : true ,
1057
+ } ,
1058
+ {
1059
+ name : "hyperv" ,
1060
+ url : "#{ box_path } " ,
1061
+ architecture : "test-arch" ,
1062
+ default_architecture : true ,
1063
+ }
1064
+ ]
1065
+ }
1066
+ ]
1067
+ } . to_json
1068
+ )
1069
+ f . close
1070
+ end
1071
+
1072
+ env [ :box_url ] = tf . path
1073
+ expect ( box_collection ) . to receive ( :add ) . with ( any_args ) { |path , name , version , opts |
1074
+ expect ( checksum ( path ) ) . to eq ( checksum ( box_path ) )
1075
+ expect ( name ) . to eq ( "foo/bar" )
1076
+ expect ( version ) . to eq ( "0.7" )
1077
+ expect ( opts [ :metadata_url ] ) . to eq ( "file://#{ tf . path } " )
1078
+ expect ( opts [ :architecture ] ) . to eq ( "test-arch" )
1079
+ true
1080
+ } . and_return ( box )
1081
+
1082
+ expect ( app ) . to receive ( :call ) . with ( env )
1083
+
1084
+ subject . call ( env )
1085
+ end
1086
+
1036
1087
it "adds the latest version of a box with only one provider and unknown architecture set as default" do
1037
1088
box_path = iso_env . box2_file ( :virtualbox )
1038
1089
tf = Tempfile . new ( [ "vagrant-box-latest-version" , ".json" ] ) . tap do |f |
0 commit comments