LukeMathWalker / LukeMathWalker/wiremock-rs

Simulate connect delay

Open
#19 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
799
Forks
91
PR merge metrics
No merged PRs in 30d

Description

Hey,

thanks for the crate.

I'm building a [link checker](https://github.com/hello-rust/lychee) and I need a way to simulate a connect delay.
Here's a little snippet to show what I tried:

```rust
#[tokio::test]
async fn test_timeout() {
let mock_server = MockServer::start().await;
let delay = Duration::from_secs(30);
let template = ResponseTemplate::new(200).set_delay(delay.clone());
Mock::given(method("GET"))
.respond_with(template)
.mount(&mock_server)
.await;

let res = get_checker(false, HeaderMap::new())
.check(&Url::parse(&mock_server.uri()).unwrap())
.await;
assert!(matches!(res, Status::Timeout));
}
```

`get_checker` is just a wrapper around reqwest.

This didn't work. It's obvious, in hindsight, because I was mixing up the _response_ delay with a _connect_ delay.
Any way I could test that right now? Maybe there could be another parameter `set_connect_delay` for that?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names MockServer and ResponseTemplate::set_delay but no repository file or test path. Start by tracing how set_delay is implemented and how MockServer accepts connections, then compare the behavior with the shown reqwest timeout test. Done means a connect-delay capability is exposed and the timeout scenario can be tested reliably.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.