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,45 +507,60 @@ 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 {
client let client = client.clone();
.has_release_artifact(GhReleaseArtifact { let release = release.clone();
release: release.clone(), tasks.push(tokio::spawn(async move {
artifact_name: artifact_name.to_compact_string(), client
}) .has_release_artifact(GhReleaseArtifact {
.await release,
.unwrap() artifact_name: artifact_name.to_compact_string(),
.unwrap(); })
.await
.unwrap()
.unwrap();
}));
} }
assert_eq!( let client = client.clone();
client tasks.push(tokio::spawn(async move {
.has_release_artifact(GhReleaseArtifact { assert_eq!(
release: release.clone(), client
artifact_name: "123z".to_compact_string(), .has_release_artifact(GhReleaseArtifact {
}) release,
.await artifact_name: "123z".to_compact_string(),
.unwrap(), })
None .await
); .unwrap(),
None
);
}));
} }
for release in NON_EXISTENT_RELEASES { for release in NON_EXISTENT_RELEASES {
assert_eq!( let client = client.clone();
client
.has_release_artifact(GhReleaseArtifact { tasks.push(tokio::spawn(async move {
release, assert_eq!(
artifact_name: "1234".to_compact_string(), client
}) .has_release_artifact(GhReleaseArtifact {
.await release,
.unwrap(), artifact_name: "1234".to_compact_string(),
None })
); .await
.unwrap(),
None
);
}));
} }
} }
for task in tasks {
task.await.unwrap();
}
} }
} }