|
|
|
@ -86,12 +86,14 @@ impl RegistryConfig {
|
|
|
|
|
out = out.replace("{sha256-checksum}", cksum); |
|
|
|
|
out |
|
|
|
|
} else { |
|
|
|
|
format!( |
|
|
|
|
"{dl}/{name}/{version}/download", |
|
|
|
|
dl = self.dl, |
|
|
|
|
Path::new(&self.dl) |
|
|
|
|
.join(&format!( |
|
|
|
|
"{name}/{version}/download", |
|
|
|
|
name = name, |
|
|
|
|
version = version, |
|
|
|
|
) |
|
|
|
|
)) |
|
|
|
|
.display() |
|
|
|
|
.to_string() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -808,4 +810,25 @@ mod tests {
|
|
|
|
|
|
|
|
|
|
assert_eq!(output_path, Path::new("output/lazy-static/x7b2z899"),); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn verify_blank_url_template_works_same_as_default() { |
|
|
|
|
let c1 = RegistryConfig { |
|
|
|
|
dl: "{crate}/{version}/download".to_string(), |
|
|
|
|
api: String::new(), |
|
|
|
|
allowed_registries: vec![], |
|
|
|
|
auth_required: Some(true), |
|
|
|
|
}; |
|
|
|
|
let mut c2 = c1.clone(); |
|
|
|
|
c2.dl = "".to_string(); |
|
|
|
|
|
|
|
|
|
assert_eq!( |
|
|
|
|
c1.get_dl_url("lazy-static", "1.0.0", "x7b2z899"), |
|
|
|
|
c2.get_dl_url("lazy-static", "1.0.0", "x7b2z899"), |
|
|
|
|
); |
|
|
|
|
assert_eq!( |
|
|
|
|
Path::new("output").join(c1.get_dl_url("lazy-static", "1.0.0", "x7b2z899")), |
|
|
|
|
Path::new("output/lazy-static/1.0.0/download"), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|