Skip to content

Commit

Permalink
add new package id test
Browse files Browse the repository at this point in the history
  • Loading branch information
Skgland committed Dec 18, 2024
1 parent 4759ec5 commit e729bdc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/crates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ impl TryFrom<&'_ PackageId> for Crate {
}
}
}
["registry", url, ..] => {
let Some((_registry, krate)) = url.split_once('#') else {
bail!(
"malformed pkgid format: {}\n maybe the representation has changed?",
pkgid.repr
);
};
let Some((crate_name, crate_version)) = krate.split_once('@') else {
bail!(
"malformed pkgid format: {}\n maybe the representation has changed?",
pkgid.repr
);
};
Ok(Crate::Registry(RegistryCrate {
name: crate_name.to_string(),
version: crate_version.to_string(),
}))
}
_ => bail!(
"malformed pkgid format: {}\n maybe the representation has changed?",
pkgid.repr
Expand Down Expand Up @@ -252,6 +270,10 @@ mod tests {
.to_string(),
sha: None
}),
"registry+https://github.com/rust-lang/crates.io-index#[email protected]" => Crate::Registry(RegistryCrate {
name: "cookie".to_string(),
version: "0.15.0".to_string(),
}),
}

assert!(Crate::try_from(&PackageId {
Expand Down

0 comments on commit e729bdc

Please sign in to comment.