get: cleanup, added non-git test case (xfail)
This commit is contained in:
33
src/get.rs
33
src/get.rs
@@ -185,7 +185,7 @@ pub async fn get(package: &str, _version: &str, series: &str, pocket: &str, _ppa
|
|||||||
if let Some(cb) = progress {
|
if let Some(cb) = progress {
|
||||||
cb(&format!("Resolving package info for {}...", package), "", 0, 0);
|
cb(&format!("Resolving package info for {}...", package), "", 0, 0);
|
||||||
}
|
}
|
||||||
let package_info = package_info::get(package, series, pocket).await;
|
let package_info = package_info::get(package, series, pocket).await?;
|
||||||
|
|
||||||
let package_dir = if let Some(path) = cwd {
|
let package_dir = if let Some(path) = cwd {
|
||||||
path.join(package)
|
path.join(package)
|
||||||
@@ -193,18 +193,17 @@ pub async fn get(package: &str, _version: &str, series: &str, pocket: &str, _ppa
|
|||||||
Path::new(package).to_path_buf()
|
Path::new(package).to_path_buf()
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(Some(info)) = package_info {
|
let info = package_info.unwrap();
|
||||||
if let Some(ref url) = info.preferred_vcs {
|
if let Some(ref url) = info.preferred_vcs {
|
||||||
if let Some(cb) = progress {
|
if let Some(cb) = progress {
|
||||||
cb(&format!("Cloning {}...", url), "", 0, 0);
|
cb(&format!("Cloning {}...", url), "", 0, 0);
|
||||||
}
|
|
||||||
clone_repo(url.as_str(), package, Some(&package_dir), progress)?;
|
|
||||||
|
|
||||||
if let Some(cb) = progress {
|
|
||||||
cb("Fetching orig tarball...", "", 0, 0);
|
|
||||||
}
|
|
||||||
fetch_orig_tarball(&info, Some(&package_dir), progress).await?;
|
|
||||||
}
|
}
|
||||||
|
clone_repo(url.as_str(), package, Some(&package_dir), progress)?;
|
||||||
|
|
||||||
|
if let Some(cb) = progress {
|
||||||
|
cb("Fetching orig tarball...", "", 0, 0);
|
||||||
|
}
|
||||||
|
fetch_orig_tarball(&info, Some(&package_dir), progress).await?;
|
||||||
} else {
|
} else {
|
||||||
return Err(format!("No VCS URL found for package {}", package).into());
|
return Err(format!("No VCS URL found for package {}", package).into());
|
||||||
}
|
}
|
||||||
@@ -254,4 +253,14 @@ mod tests {
|
|||||||
async fn test_get_hello_debian_end_to_end() {
|
async fn test_get_hello_debian_end_to_end() {
|
||||||
test_get_package_end_to_end("hello", "bookworm").await;
|
test_get_package_end_to_end("hello", "bookworm").await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[should_panic(expected = "No VCS URL found for package agg")]
|
||||||
|
async fn test_get_agg_svn_should_fail() {
|
||||||
|
// agg uses Vcs-Svn, which is not supported.
|
||||||
|
// We expect this to fail with "No VCS URL found".
|
||||||
|
let temp_dir = tempfile::tempdir().unwrap();
|
||||||
|
let cwd = temp_dir.path();
|
||||||
|
get("agg", "", "sid", "", "", Some(cwd), None).await.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user