Skip to content

Commit

Permalink
tests/dist.rs: Add profile to mock server
Browse files Browse the repository at this point in the history
This moves us a step closer to passing the dist tests.

Signed-off-by: Daniel Silverstone <[email protected]>
  • Loading branch information
kinnison committed May 14, 2019
1 parent f1bc569 commit dd29663
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions tests/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod mock;

use crate::mock::dist::*;
use crate::mock::{MockComponentBuilder, MockFile, MockInstallerBuilder};
use rustup::dist::dist::{TargetTriple, ToolchainDesc, DEFAULT_DIST_SERVER};
use rustup::dist::dist::{Profile, TargetTriple, ToolchainDesc, DEFAULT_DIST_SERVER};
use rustup::dist::download::DownloadCfg;
use rustup::dist::manifest::{Component, Manifest};
use rustup::dist::manifestation::{Changes, Manifestation, UpdateStatus};
Expand Down Expand Up @@ -69,6 +69,10 @@ pub fn create_mock_channel(
name: "rust-std".to_string(),
target: "x86_64-apple-darwin".to_string(),
},
MockComponent {
name: "rust-docs".to_string(),
target: "x86_64-apple-darwin".to_string(),
},
],
extensions: vec![
MockComponent {
Expand Down Expand Up @@ -98,6 +102,10 @@ pub fn create_mock_channel(
name: "rust-std".to_string(),
target: "i686-apple-darwin".to_string(),
},
MockComponent {
name: "rust-docs".to_string(),
target: "i686-apple-darwin".to_string(),
},
],
extensions: vec![],
installer: MockInstallerBuilder { components: vec![] },
Expand Down Expand Up @@ -183,6 +191,36 @@ pub fn create_mock_channel(
],
});

packages.push(MockPackage {
name: "rust-docs",
version: "1.0.0",
targets: vec![
MockTargetedPackage {
target: "x86_64-apple-darwin".to_string(),
available: true,
components: vec![],
extensions: vec![],
installer: MockInstallerBuilder {
components: vec![MockComponentBuilder {
name: "rust-docs-x86_64-apple-darwin".to_string(),
files: vec![MockFile::new_arc("share/doc/index.html", contents.clone())],
}],
},
},
MockTargetedPackage {
target: "i686-apple-darwin".to_string(),
available: true,
components: vec![],
extensions: vec![],
installer: MockInstallerBuilder {
components: vec![MockComponentBuilder {
name: "rust-docs-i686-apple-darwin".to_string(),
files: vec![MockFile::new_arc("share/doc/index.html", contents.clone())],
}],
},
},
],
});
// An extra package that can be used as a component of the other packages
// for various tests
packages.push(bonus_component("bonus", contents.clone()));
Expand Down Expand Up @@ -412,11 +450,17 @@ fn update_from_dist_(

// Read the manifest to update the components
let trip = toolchain.target.clone();
let manifestation = Manifestation::open(prefix.clone(), trip)?;
let manifestation = Manifestation::open(prefix.clone(), trip.clone())?;

let implicit_components = manifest.get_profile_components(Profile::Default)?;
let implicit_components = implicit_components
.iter()
.map(|s| Component::new(s.clone(), Some(trip.clone())))
.collect::<Vec<_>>();

let changes = Changes {
explicit_add_components: add.to_owned(),
implicit_add_components: vec![],
implicit_add_components: implicit_components,
remove_components: remove.to_owned(),
};

Expand Down

0 comments on commit dd29663

Please sign in to comment.