mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-17 08:06:38 +00:00
Parallelise test_get_repo_info
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
5f138e6655
commit
345255a65f
1 changed files with 21 additions and 18 deletions
|
@ -450,41 +450,44 @@ mod test {
|
||||||
|
|
||||||
init_logger();
|
init_logger();
|
||||||
|
|
||||||
|
let mut tests: Vec<(_, _)> = Vec::new();
|
||||||
|
|
||||||
for client in create_client().await {
|
for client in create_client().await {
|
||||||
eprintln!("In client {client:?}");
|
eprintln!("In client {client:?}");
|
||||||
|
|
||||||
for repo in PUBLIC_REPOS {
|
for repo in PUBLIC_REPOS {
|
||||||
let res = client.get_repo_info(&repo).await;
|
let client = client.clone();
|
||||||
|
|
||||||
if matches!(res, Err(GhApiError::RateLimit { .. })) {
|
tests.push((
|
||||||
continue;
|
Some(RepoInfo::new(repo.clone(), false)),
|
||||||
}
|
tokio::spawn(async move { client.get_repo_info(&repo).await }),
|
||||||
|
));
|
||||||
assert_eq!(res.unwrap(), Some(RepoInfo::new(repo, false)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for repo in NON_EXISTENT_REPOS {
|
for repo in NON_EXISTENT_REPOS {
|
||||||
let res = client.get_repo_info(&repo).await;
|
let client = client.clone();
|
||||||
|
|
||||||
if matches!(res, Err(GhApiError::RateLimit { .. })) {
|
tests.push((
|
||||||
continue;
|
None,
|
||||||
}
|
tokio::spawn(async move { client.get_repo_info(&repo).await }),
|
||||||
|
));
|
||||||
assert_eq!(res.unwrap(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.get_auth_token().is_some() {
|
if client.get_auth_token().is_some() {
|
||||||
for repo in PRIVATE_REPOS {
|
for repo in PRIVATE_REPOS {
|
||||||
let res = client.get_repo_info(&repo).await;
|
let client = client.clone();
|
||||||
|
|
||||||
if matches!(res, Err(GhApiError::RateLimit { .. })) {
|
tests.push((
|
||||||
continue;
|
Some(RepoInfo::new(repo.clone(), true)),
|
||||||
}
|
tokio::spawn(async move { client.get_repo_info(&repo).await }),
|
||||||
|
));
|
||||||
assert_eq!(res.unwrap(), Some(RepoInfo::new(repo, true)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (expected, task) in tests {
|
||||||
|
assert_eq!(task.await.unwrap().unwrap(), expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn test_specific_release(release: &GhRelease, artifacts: &[&str]) {
|
async fn test_specific_release(release: &GhRelease, artifacts: &[&str]) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue