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