Skip to content

Commit 06fb8bc

Browse files
rbtcollinsDarunada
authored andcommitted
Migrate HostGoesMissing
1 parent 92af832 commit 06fb8bc

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

tests/cli-rustup.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustup::for_host;
1010
use rustup::test::this_host_triple;
1111
use rustup::utils::raw;
1212

13-
use crate::mock::clitools::{self, set_current_dist_date, Config, Scenario};
13+
use crate::mock::clitools::{self, Config, Scenario};
1414

1515
macro_rules! for_host_and_home {
1616
($config:ident, $s: expr) => {
@@ -2125,15 +2125,16 @@ fn non_utf8_toolchain() {
21252125

21262126
#[test]
21272127
fn check_host_goes_away() {
2128-
// TODO:migrate to with-scenario
2129-
clitools::test(Scenario::HostGoesMissing, &|config| {
2130-
set_current_dist_date(config, "2019-12-09");
2131-
config.expect_ok(&["rustup", "default", "nightly"]);
2132-
set_current_dist_date(config, "2019-12-10");
2133-
config.expect_err(
2134-
&["rustup", "update", "nightly"],
2135-
for_host!("target '{}' not found in channel"),
2136-
);
2128+
test(&|config| {
2129+
config.with_scenario(Scenario::HostGoesMissingBefore, &|config| {
2130+
config.expect_ok(&["rustup", "default", "nightly"]);
2131+
});
2132+
config.with_scenario(Scenario::HostGoesMissingAfter, &|config| {
2133+
config.expect_err(
2134+
&["rustup", "update", "nightly"],
2135+
for_host!("target '{}' not found in channel"),
2136+
);
2137+
})
21372138
})
21382139
}
21392140

tests/mock/clitools.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ pub enum Scenario {
8888
MissingComponent,
8989
/// Three dates, v2 manifests, RLS available in first, middle missing nightly
9090
MissingNightly,
91-
/// Two dates, v2 manifests, host and MULTI_ARCH1 in first, host not in second
92-
HostGoesMissing,
91+
/// 1 date, v2 manifests, host and MULTI_ARCH1 in first
92+
HostGoesMissingBefore,
93+
/// 1 later date, v2 manifests, MULTI_ARCH1 only
94+
HostGoesMissingAfter,
9395
/// Three dates, v2 manifests, host and MULTI_ARCH1 in first, host only in second,
9496
/// host and MULTI_ARCH1 but no RLS in last
9597
MissingComponentMulti,
@@ -124,7 +126,8 @@ impl ConstState {
124126
Scenario::ArchivesV2TwoVersions => RwLock::new(None),
125127
Scenario::Empty => RwLock::new(None),
126128
Scenario::Full => RwLock::new(None),
127-
Scenario::HostGoesMissing => RwLock::new(None),
129+
Scenario::HostGoesMissingBefore => RwLock::new(None),
130+
Scenario::HostGoesMissingAfter => RwLock::new(None),
128131
Scenario::MissingComponent => RwLock::new(None),
129132
Scenario::MissingComponentMulti => RwLock::new(None),
130133
Scenario::MissingNightly => RwLock::new(None),
@@ -1027,10 +1030,12 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
10271030
Release::beta("1.2.0", "2015-01-02").multi_arch(),
10281031
Release::stable("1.1.0", "2015-01-02").multi_arch(),
10291032
],
1030-
Scenario::HostGoesMissing => vec![
1031-
Release::new("nightly", "1.3.0", "2019-12-09", "1"),
1032-
Release::new("nightly", "1.3.0", "2019-12-10", "2").only_multi_arch(),
1033-
],
1033+
Scenario::HostGoesMissingBefore => {
1034+
vec![Release::new("nightly", "1.3.0", "2019-12-09", "1")]
1035+
}
1036+
Scenario::HostGoesMissingAfter => {
1037+
vec![Release::new("nightly", "1.3.0", "2019-12-10", "2").only_multi_arch()]
1038+
}
10341039
Scenario::MissingComponentMulti => vec![
10351040
Release::new("nightly", "1.37.0", "2019-09-12", "1")
10361041
.multi_arch()
@@ -1055,7 +1060,8 @@ fn create_mock_dist_server(path: &Path, s: Scenario) {
10551060
| Scenario::Unavailable
10561061
| Scenario::UnavailableRls
10571062
| Scenario::MissingNightly
1058-
| Scenario::HostGoesMissing
1063+
| Scenario::HostGoesMissingBefore
1064+
| Scenario::HostGoesMissingAfter
10591065
| Scenario::MissingComponent
10601066
| Scenario::MissingComponentMulti => vec![ManifestVersion::V2],
10611067
};

0 commit comments

Comments
 (0)