Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 2 additions & 44 deletions lychee-bin/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ mod cli {
io::{BufRead, Write},
ops::Not,
path::Path,
time::{Duration, Instant},
time::Duration,
};
use tempfile::{NamedTempFile, tempdir};
use test_utils::{fixtures_path, mock_server, redirecting_mock_server, root_path};
use url::Url;

use uuid::Uuid;
use wiremock::{
Mock, Request, ResponseTemplate,
Mock, ResponseTemplate,
matchers::{basic_auth, method, path},
};

Expand Down Expand Up @@ -2786,48 +2786,6 @@ The config file should contain every possible key for documentation purposes."
.success();
}

#[tokio::test]
async fn test_retry_rate_limit_headers() {
const RETRY_DELAY: Duration = Duration::from_secs(1);
const TOLERANCE: Duration = Duration::from_millis(500);
let server = wiremock::MockServer::start().await;

wiremock::Mock::given(wiremock::matchers::method("GET"))
.respond_with(
ResponseTemplate::new(429)
.append_header("Retry-After", RETRY_DELAY.as_secs().to_string()),
)
.expect(1)
.up_to_n_times(1)
.mount(&server)
.await;

let start = Instant::now();
wiremock::Mock::given(wiremock::matchers::method("GET"))
.respond_with(move |_: &Request| {
let delta = Instant::now().duration_since(start);
assert!(delta > RETRY_DELAY);
assert!(delta < RETRY_DELAY + TOLERANCE);
ResponseTemplate::new(200)
})
.expect(1)
.mount(&server)
.await;

cargo_bin_cmd!()
// Direct args are not using the host pool, they are resolved earlier via Collector
.arg("-")
// Retry wait times are added on top of host-specific backoff timeout
.arg("--retry-wait-time")
.arg("0")
.write_stdin(server.uri())
.assert()
.success();

// Check that the server received the request with the header
server.verify().await;
}

#[tokio::test]
async fn test_no_header_set_on_input() {
let server = wiremock::MockServer::start().await;
Expand Down
Loading
Loading