Skip to content

Commit b4d9116

Browse files
committed
Fix beta checking from exact match to prefix (#652)
1 parent bcdb5f8 commit b4d9116

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/channel.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ pub struct Package {
3535
pub fuels_version: Option<String>,
3636
}
3737

38-
pub fn is_beta_toolchain(name: &str) -> bool {
39-
name == BETA_1
40-
|| name == BETA_2
41-
|| name == BETA_3
42-
|| name == BETA_4
43-
|| name == BETA_5
44-
|| name == DEVNET
45-
|| name == TESTNET
38+
pub fn is_beta_toolchain(name: &str) -> Option<&str> {
39+
BETA_CHANNELS
40+
.iter()
41+
.find(|&beta_channel| name.starts_with(beta_channel))
42+
.copied()
4643
}
4744

4845
fn format_nightly_url(date: &Date) -> Result<String> {
@@ -231,4 +228,14 @@ mod tests {
231228
assert_eq!(cfgs[1].name, "fuel-core");
232229
assert_eq!(cfgs[1].version, Version::parse("0.9.4").unwrap());
233230
}
231+
232+
#[test]
233+
fn test_all_channels_for_beta() {
234+
for channel in CHANNELS.iter() {
235+
assert_eq!(
236+
is_beta_toolchain(channel).is_some(),
237+
BETA_CHANNELS.contains(channel)
238+
);
239+
}
240+
}
234241
}

src/toolchain_override.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ impl fmt::Display for Channel {
8888
impl FromStr for Channel {
8989
type Err = anyhow::Error;
9090
fn from_str(s: &str) -> Result<Self> {
91-
if is_beta_toolchain(s) {
91+
if let Some(beta_channel) = is_beta_toolchain(s) {
9292
return Ok(Self {
93-
name: s.to_string(),
93+
name: beta_channel.to_string(),
9494
date: None,
9595
});
9696
};

0 commit comments

Comments
 (0)