mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 07:36:38 +00:00
Fix test_has_release_artifact_and_download_artifacts
Retry on rate limit Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
999ebb964c
commit
dfa2649409
1 changed files with 32 additions and 19 deletions
|
@ -602,6 +602,20 @@ mod test {
|
||||||
let mut tasks = Vec::new();
|
let mut tasks = Vec::new();
|
||||||
|
|
||||||
for client in create_client() {
|
for client in create_client() {
|
||||||
|
async fn has_release_artifact(
|
||||||
|
client: &GhApiClient,
|
||||||
|
artifact: &GhReleaseArtifact,
|
||||||
|
) -> Result<Option<GhReleaseArtifactUrl>, GhApiError> {
|
||||||
|
loop {
|
||||||
|
match client.has_release_artifact(artifact.clone()).await {
|
||||||
|
Err(GhApiError::RateLimit { retry_after }) => {
|
||||||
|
sleep(retry_after.unwrap_or(DEFAULT_RETRY_AFTER)).await
|
||||||
|
}
|
||||||
|
res => break res,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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 client = client.clone();
|
||||||
|
@ -628,15 +642,10 @@ mod test {
|
||||||
.into_bytes(),
|
.into_bytes(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
let artifact_url = has_release_artifact(&client, &artifact)
|
||||||
let artifact_url = loop {
|
.await
|
||||||
match client.has_release_artifact(artifact.clone()).await {
|
.unwrap()
|
||||||
Err(GhApiError::RateLimit { retry_after }) => {
|
.unwrap();
|
||||||
sleep(retry_after.unwrap_or(DEFAULT_RETRY_AFTER)).await
|
|
||||||
}
|
|
||||||
res => break res.unwrap().unwrap(),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(browser_download_task) = browser_download_task {
|
if let Some(browser_download_task) = browser_download_task {
|
||||||
let artifact_download_data = loop {
|
let artifact_download_data = loop {
|
||||||
|
@ -662,13 +671,15 @@ mod test {
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
tasks.push(tokio::spawn(async move {
|
tasks.push(tokio::spawn(async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
client
|
has_release_artifact(
|
||||||
.has_release_artifact(GhReleaseArtifact {
|
&client,
|
||||||
|
&GhReleaseArtifact {
|
||||||
release,
|
release,
|
||||||
artifact_name: "123z".to_compact_string(),
|
artifact_name: "123z".to_compact_string(),
|
||||||
})
|
}
|
||||||
.await
|
)
|
||||||
.unwrap(),
|
.await
|
||||||
|
.unwrap(),
|
||||||
None
|
None
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
@ -679,13 +690,15 @@ mod test {
|
||||||
|
|
||||||
tasks.push(tokio::spawn(async move {
|
tasks.push(tokio::spawn(async move {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
client
|
has_release_artifact(
|
||||||
.has_release_artifact(GhReleaseArtifact {
|
&client,
|
||||||
|
&GhReleaseArtifact {
|
||||||
release,
|
release,
|
||||||
artifact_name: "1234".to_compact_string(),
|
artifact_name: "1234".to_compact_string(),
|
||||||
})
|
}
|
||||||
.await
|
)
|
||||||
.unwrap(),
|
.await
|
||||||
|
.unwrap(),
|
||||||
None
|
None
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue