@@ -51,7 +51,9 @@ pub fn create_mock_channel(channel: &str, date: &str,
5151 // Put the date in the files so they can be differentiated
5252 let contents = Arc :: new ( date. as_bytes ( ) . to_vec ( ) ) ;
5353
54- let rust_pkg = MockPackage {
54+ let mut packages = Vec :: with_capacity ( 5 ) ;
55+
56+ packages. push ( MockPackage {
5557 name : "rust" ,
5658 version : "1.0.0" ,
5759 targets : vec ! [
@@ -63,6 +65,10 @@ pub fn create_mock_channel(channel: &str, date: &str,
6365 name: "rustc" . to_string( ) ,
6466 target: "x86_64-apple-darwin" . to_string( ) ,
6567 } ,
68+ MockComponent {
69+ name: "cargo" . to_string( ) ,
70+ target: "x86_64-apple-darwin" . to_string( ) ,
71+ } ,
6672 MockComponent {
6773 name: "rust-std" . to_string( ) ,
6874 target: "x86_64-apple-darwin" . to_string( ) ,
@@ -90,6 +96,10 @@ pub fn create_mock_channel(channel: &str, date: &str,
9096 name: "rustc" . to_string( ) ,
9197 target: "i686-apple-darwin" . to_string( ) ,
9298 } ,
99+ MockComponent {
100+ name: "cargo" . to_string( ) ,
101+ target: "i686-apple-darwin" . to_string( ) ,
102+ } ,
93103 MockComponent {
94104 name: "rust-std" . to_string( ) ,
95105 target: "i686-apple-darwin" . to_string( ) ,
@@ -101,39 +111,42 @@ pub fn create_mock_channel(channel: &str, date: &str,
101111 }
102112 }
103113 ]
104- } ;
114+ } ) ;
105115
106- let rustc_pkg = MockPackage {
107- name : "rustc" ,
108- version : "1.0.0" ,
109- targets : vec ! [
110- MockTargetedPackage {
111- target: "x86_64-apple-darwin" . to_string( ) ,
112- available: true ,
113- components: vec![ ] ,
114- extensions: vec![ ] ,
115- installer: MockInstallerBuilder {
116- components: vec![ MockComponentBuilder {
117- name: "rustc" . to_string( ) ,
118- files: vec![
119- MockFile :: new_arc( "bin/rustc" , contents. clone( ) ) ,
120- ] ,
121- } ] ,
122- }
123- } ,
124- MockTargetedPackage {
125- target: "i686-apple-darwin" . to_string( ) ,
126- available: true ,
127- components: vec![ ] ,
128- extensions: vec![ ] ,
129- installer: MockInstallerBuilder {
130- components: vec![ ]
131- }
132- }
133- ]
134- } ;
116+ for bin in & [ "bin/rustc" , "bin/cargo" ] {
117+ let pkg = & bin[ 4 ..] ;
118+ packages. push ( MockPackage {
119+ name : pkg,
120+ version : "1.0.0" ,
121+ targets : vec ! [
122+ MockTargetedPackage {
123+ target: "x86_64-apple-darwin" . to_string( ) ,
124+ available: true ,
125+ components: vec![ ] ,
126+ extensions: vec![ ] ,
127+ installer: MockInstallerBuilder {
128+ components: vec![ MockComponentBuilder {
129+ name: pkg. to_string( ) ,
130+ files: vec![
131+ MockFile :: new_arc( * bin, contents. clone( ) ) ,
132+ ] ,
133+ } ] ,
134+ }
135+ } ,
136+ MockTargetedPackage {
137+ target: "i686-apple-darwin" . to_string( ) ,
138+ available: true ,
139+ components: vec![ ] ,
140+ extensions: vec![ ] ,
141+ installer: MockInstallerBuilder {
142+ components: vec![ ]
143+ }
144+ } ,
145+ ] ,
146+ } ) ;
147+ }
135148
136- let std_pkg = MockPackage {
149+ packages . push ( MockPackage {
137150 name : "rust-std" ,
138151 version : "1.0.0" ,
139152 targets : vec ! [
@@ -180,26 +193,20 @@ pub fn create_mock_channel(channel: &str, date: &str,
180193 }
181194 } ,
182195 ]
183- } ;
196+ } ) ;
184197
185198 // An extra package that can be used as a component of the other packages
186199 // for various tests
187- let bonus_pkg = bonus_component ( "bonus" , contents. clone ( ) ) ;
200+ packages . push ( bonus_component ( "bonus" , contents. clone ( ) ) ) ;
188201
189- let mut rust_pkg = rust_pkg;
190202 if let Some ( edit) = edit {
191- edit ( date, & mut rust_pkg ) ;
203+ edit ( date, & mut packages [ 0 ] ) ;
192204 }
193205
194206 MockChannel {
195207 name : channel. to_string ( ) ,
196208 date : date. to_string ( ) ,
197- packages : vec ! [
198- rust_pkg,
199- rustc_pkg,
200- std_pkg,
201- bonus_pkg,
202- ] ,
209+ packages,
203210 renames : HashMap :: new ( ) ,
204211 }
205212}
@@ -270,7 +277,7 @@ fn rename_component() {
270277
271278 let date_2 = "2016-02-02" ;
272279 let mut channel_2 = create_mock_channel ( "nightly" , date_2, Some ( edit_2) ) ;
273- channel_2. packages [ 3 ] = bonus_component ( "bobo" , Arc :: new ( date_2. as_bytes ( ) . to_vec ( ) ) ) ;
280+ channel_2. packages [ 4 ] = bonus_component ( "bobo" , Arc :: new ( date_2. as_bytes ( ) . to_vec ( ) ) ) ;
274281 channel_2. renames . insert ( "bonus" . to_owned ( ) , "bobo" . to_owned ( ) ) ;
275282 let mock_dist_server = MockDistServer {
276283 path : dist_tempdir. path ( ) . to_owned ( ) ,
@@ -309,10 +316,10 @@ fn rename_component_ignore() {
309316
310317 let date_1 = "2016-02-01" ;
311318 let mut channel_1 = create_mock_channel ( "nightly" , date_1, Some ( edit) ) ;
312- channel_1. packages [ 3 ] = bonus_component ( "bobo" , Arc :: new ( date_1. as_bytes ( ) . to_vec ( ) ) ) ;
319+ channel_1. packages [ 4 ] = bonus_component ( "bobo" , Arc :: new ( date_1. as_bytes ( ) . to_vec ( ) ) ) ;
313320 let date_2 = "2016-02-02" ;
314321 let mut channel_2 = create_mock_channel ( "nightly" , date_2, Some ( edit) ) ;
315- channel_2. packages [ 3 ] = bonus_component ( "bobo" , Arc :: new ( date_2. as_bytes ( ) . to_vec ( ) ) ) ;
322+ channel_2. packages [ 4 ] = bonus_component ( "bobo" , Arc :: new ( date_2. as_bytes ( ) . to_vec ( ) ) ) ;
316323 channel_2. renames . insert ( "bonus" . to_owned ( ) , "bobo" . to_owned ( ) ) ;
317324 let mock_dist_server = MockDistServer {
318325 path : dist_tempdir. path ( ) . to_owned ( ) ,
@@ -351,7 +358,7 @@ fn rename_component_new() {
351358
352359 let date_2 = "2016-02-02" ;
353360 let mut channel_2 = create_mock_channel ( "nightly" , date_2, Some ( edit_2) ) ;
354- channel_2. packages [ 3 ] = bonus_component ( "bobo" , Arc :: new ( date_2. as_bytes ( ) . to_vec ( ) ) ) ;
361+ channel_2. packages [ 4 ] = bonus_component ( "bobo" , Arc :: new ( date_2. as_bytes ( ) . to_vec ( ) ) ) ;
355362 channel_2. renames . insert ( "bonus" . to_owned ( ) , "bobo" . to_owned ( ) ) ;
356363 let mock_dist_server = MockDistServer {
357364 path : dist_tempdir. path ( ) . to_owned ( ) ,
0 commit comments