Parallelize test_has_release_artifact

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2024-05-30 00:57:49 +10:00
parent 4ffaf8c805
commit 9f3156cea5
No known key found for this signature in database
GPG key ID: 76D1E687CA3C4928

View file

@ -448,8 +448,6 @@ mod test {
let mut tests: Vec<(_, _)> = Vec::new();
for client in create_client().await {
eprintln!("In client {client:?}");
for repo in PUBLIC_REPOS {
let client = client.clone();
@ -509,34 +507,44 @@ mod test {
init_logger();
for client in create_client().await {
eprintln!("In client {client:?}");
let mut tasks = Vec::new();
for client in create_client().await {
for (release, artifacts) in RELEASES {
for artifact_name in artifacts {
let client = client.clone();
let release = release.clone();
tasks.push(tokio::spawn(async move {
client
.has_release_artifact(GhReleaseArtifact {
release: release.clone(),
release,
artifact_name: artifact_name.to_compact_string(),
})
.await
.unwrap()
.unwrap();
}));
}
let client = client.clone();
tasks.push(tokio::spawn(async move {
assert_eq!(
client
.has_release_artifact(GhReleaseArtifact {
release: release.clone(),
release,
artifact_name: "123z".to_compact_string(),
})
.await
.unwrap(),
None
);
}));
}
for release in NON_EXISTENT_RELEASES {
let client = client.clone();
tasks.push(tokio::spawn(async move {
assert_eq!(
client
.has_release_artifact(GhReleaseArtifact {
@ -547,7 +555,12 @@ mod test {
.unwrap(),
None
);
}
}));
}
}
for task in tasks {
task.await.unwrap();
}
}
}