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,40 +450,43 @@ mod test {
|
|||
|
||||
init_logger();
|
||||
|
||||
let mut tests: Vec<(_, _)> = Vec::new();
|
||||
|
||||
for client in create_client().await {
|
||||
eprintln!("In client {client:?}");
|
||||
|
||||
for repo in PUBLIC_REPOS {
|
||||
let res = client.get_repo_info(&repo).await;
|
||||
let client = client.clone();
|
||||
|
||||
if matches!(res, Err(GhApiError::RateLimit { .. })) {
|
||||
continue;
|
||||
}
|
||||
|
||||
assert_eq!(res.unwrap(), Some(RepoInfo::new(repo, false)));
|
||||
tests.push((
|
||||
Some(RepoInfo::new(repo.clone(), false)),
|
||||
tokio::spawn(async move { client.get_repo_info(&repo).await }),
|
||||
));
|
||||
}
|
||||
|
||||
for repo in NON_EXISTENT_REPOS {
|
||||
let res = client.get_repo_info(&repo).await;
|
||||
let client = client.clone();
|
||||
|
||||
if matches!(res, Err(GhApiError::RateLimit { .. })) {
|
||||
continue;
|
||||
}
|
||||
|
||||
assert_eq!(res.unwrap(), None);
|
||||
tests.push((
|
||||
None,
|
||||
tokio::spawn(async move { client.get_repo_info(&repo).await }),
|
||||
));
|
||||
}
|
||||
|
||||
if client.get_auth_token().is_some() {
|
||||
for repo in PRIVATE_REPOS {
|
||||
let res = client.get_repo_info(&repo).await;
|
||||
let client = client.clone();
|
||||
|
||||
if matches!(res, Err(GhApiError::RateLimit { .. })) {
|
||||
continue;
|
||||
tests.push((
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue