8000 GitHub - nkzou/rvcr: Record-and-replay testing middleware for reqwest http client.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ rvcr Public
forked from ChorusOne/rvcr

Record-and-replay testing middleware for reqwest http client.

License

Notifications You must be signed in to change notification settings

nkzou/rvcr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rvcr

crates.io

Record-and-replay testing middleware for reqwest http client.

Inspired by:

Builds on top of:

Examples

To record HTTP requests, initialize client like following

  use std::path::PathBuf;
  use reqwest::Client;
  use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
  use rvcr::{VCRMiddleware, VCRMode};

  let mut bundle = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
  bundle.push("tests/resources/replay.vcr.json");

  let middleware: VCRMiddleware = VCRMiddleware::try_from(bundle.clone())
      .unwrap()
      .with_mode(VCRMode::Record);

  let vcr_client: ClientWithMiddleware = ClientBuilder::new(reqwest::Client::new())
      .with(middleware)
      .build();

Now ClientWithMiddleware instance will be recording requests to a file located in tests/resources/replay.vcr.json inside the project.

To use recorded VCR cassette files, replace .with_mode(VCRMode::Record) with .with_mode(VCRMode::Replay), or omit it, since replay is used by default.

Search mode

When replaying, rVCR can skip requests already found when searching for subsequent requests (the default). To disable skipping requests, which is useful, for example, if requests are done in parallel and responses may come in random order, use .with_search(VCRReplaySearch::SearchAll).

VCR cassette fie compression

Sometimes VCR files can be too large and this harder to maintain in a version control system.

To save some space and turn on bzip2 compression for artifacts, use .compression(true) method of the builder.

About

Record-and-replay testing middleware for reqwest http client.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%
0