aws_smithy_runtime::client::http::test_util

Module wire

source
Available on crate features client and test-util and connector-hyper-0-14-x and wire-mock only.
Expand description

Utilities for mocking at the socket level

Other tools in this module actually operate at the http::Request / http::Response level. This is useful, but it shortcuts the HTTP implementation (e.g. Hyper). WireMockServer binds to an actual socket on the host.

§Examples

use aws_smithy_runtime_api::client::http::HttpConnectorSettings;
use aws_smithy_runtime::client::http::test_util::wire::{check_matches, ReplayedEvent, WireMockServer};
use aws_smithy_runtime::{match_events, ev};

// This connection binds to a local address
let mock = WireMockServer::start(vec![
    ReplayedEvent::status(503),
    ReplayedEvent::status(200)
]).await;

// Create a client using the wire mock
let config = my_generated_client::Config::builder()
    .http_client(mock.http_client())
    .build();
let client = Client::from_conf(config);

// ... do something with <client>

// assert that you got the events you expected
match_events!(ev!(dns), ev!(connect), ev!(http(200)))(&mock.events());

Macros§

  • Helper to generate match expressions for events
  • Helper macro to generate a series of test expectations

Structs§

Enums§

Functions§