Skip to content

Commit

Permalink
add 2 test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
StackOverflowExcept1on authored and d-e-s-o committed Aug 15, 2024
1 parent 2ea74d9 commit 23578b7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,44 @@ mod tests {
assert_eq!(&crate_path("abcd"), Path::new("ab/cd"));
assert_eq!(&crate_path("ydasdayusiy"), Path::new("yd/as"));
}

#[test]
fn convert_simple_dependency() {
// rand = { version = "0.8.5" }
let dep = Dep {
name: "rand".into(),
version_req: "0.8.5".into(),
features: vec![],
optional: false,
default_features: true,
target: None,
kind: Kind::Normal,
registry: None,
explicit_name_in_toml: None,
};

let index_dep = crate::index::Dep::from(dep);
assert_eq!(index_dep.name.as_str(), "rand"); // name of dependency
assert_eq!(index_dep.package, None); // null if dependency is not renamed
}

#[test]
fn convert_renamed_dependency() {
// renamed-rand = { version = "0.8.5", package = "rand" }
let dep = Dep {
name: "rand".into(),
version_req: "0.8.5".into(),
features: vec![],
optional: false,
default_features: true,
target: None,
kind: Kind::Normal,
registry: None,
explicit_name_in_toml: Some("renamed-rand".into()),
};

let index_dep = crate::index::Dep::from(dep);
assert_eq!(index_dep.name.as_str(), "renamed-rand"); // new name dependency was renamed to
assert_eq!(index_dep.package, Some("rand".into())); // name of dependency package
}
}

0 comments on commit 23578b7

Please sign in to comment.