From 8f83081b031e9dc21e2a12cd6ee3ce245db88c4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 12:58:54 +0200 Subject: [PATCH] Bump octocrab from 0.28.0 to 0.29.1 (#1193) * Bump octocrab from 0.28.0 to 0.29.1 Bumps [octocrab](https://github.com/XAMPPRocky/octocrab) from 0.28.0 to 0.29.1. - [Release notes](https://github.com/XAMPPRocky/octocrab/releases) - [Changelog](https://github.com/XAMPPRocky/octocrab/blob/main/CHANGELOG.md) - [Commits](https://github.com/XAMPPRocky/octocrab/compare/v0.28.0...v0.29.1) --- updated-dependencies: - dependency-name: octocrab dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Make wayback suggestion test more robust - Retry mechanism - Better checks --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matthias --- Cargo.lock | 4 ++-- lychee-bin/src/archive/wayback/mod.rs | 27 ++++++++++++++++++++------- lychee-lib/Cargo.toml | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d4647a9..641fd65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2367,9 +2367,9 @@ dependencies = [ [[package]] name = "octocrab" -version = "0.28.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0943920a77d028b66ebe4407813733ad4d0ebe7b12dafd608ddec8478e5fef0b" +checksum = "a2f5937fa816ca24c81cd817637a29be1eb9be0b4ddfccf3783df3eb095cc4f6" dependencies = [ "arc-swap", "async-trait", diff --git a/lychee-bin/src/archive/wayback/mod.rs b/lychee-bin/src/archive/wayback/mod.rs index aff0977..4033186 100644 --- a/lychee-bin/src/archive/wayback/mod.rs +++ b/lychee-bin/src/archive/wayback/mod.rs @@ -57,16 +57,29 @@ where mod tests { use crate::archive::wayback::get_wayback_link; use reqwest::Error; + use std::{error::Error as StdError, time::Duration}; + use tokio::time::sleep; #[tokio::test] - async fn wayback_suggestion() -> Result<(), Error> { - let url = &"https://example.com".try_into().unwrap(); - let response = get_wayback_link(url).await?; - let suggestion = response.unwrap(); + async fn wayback_suggestion() -> Result<(), Box> { + let url = "https://example.com".parse()?; - assert!(suggestion.as_str().contains("web.archive.org")); - - Ok(()) + // This test can be flaky, because the wayback machine does not always + // return a suggestion. Retry a few times if needed. + for _ in 0..3 { + if let Some(suggestion) = get_wayback_link(&url).await? { + assert_eq!( + suggestion + .host_str() + .expect("Suggestion doesn't have a host"), + "web.archive.org" + ); + assert!(suggestion.path().ends_with(url.as_str())); + return Ok(()); + } + sleep(Duration::from_secs(1)).await; // add delay between retries + } + Err("Did not get a valid Wayback Machine suggestion.".into()) } #[tokio::test] diff --git a/lychee-lib/Cargo.toml b/lychee-lib/Cargo.toml index 3881dfb..dd57aa8 100644 --- a/lychee-lib/Cargo.toml +++ b/lychee-lib/Cargo.toml @@ -32,7 +32,7 @@ ip_network = "0.4.1" jwalk = "0.8.1" linkify = "0.10.0" log = "0.4.19" -octocrab = "0.28.0" +octocrab = "0.29.1" once_cell = "1.18.0" openssl-sys = { version = "0.9.90", optional = true } path-clean = "1.0.1"