Unverified Commit 90f116c5 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Refactor errors to expose a kind & meta field separately (#249)

* Refactor errors to expose a kind & meta field separately

* More simplification of errors

* Simplify the retryable_error_kind implementation

* Error generator cleanups

* Fix aws-hyper feature issue

* Small test-util refactoring to improve debug output
parent 3308fef8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -36,3 +36,7 @@ protocol-test-helpers = { path = "../../../rust-runtime/protocol-test-helpers",
tokio = { version = "1", features = ["full", "test-util"] }
tower-test = "0.4.0"
aws-types = { path = "../aws-types" }

[[test]]
name = "e2e_test"
required-features = ["test-util"]
+1 −9
Original line number Diff line number Diff line
@@ -136,21 +136,13 @@ where

#[cfg(test)]
mod tests {
    use crate::test_connection::TestConnection;
    use crate::{conn, Client};
    use crate::Client;

    #[test]
    fn construct_default_client() {
        let _ = Client::https();
    }

    #[test]
    fn construct_test_client() {
        let test_conn = TestConnection::<String>::new(vec![]);
        let client = Client::new(conn::Standard::new(test_conn));
        is_send_sync(client);
    }

    #[test]
    fn client_debug_includes_retry_info() {
        let client = Client::https();
+10 −0
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ impl<B: Into<hyper::Body>> tower::Service<http::Request<SdkBody>> for TestConnec
#[cfg(test)]
mod tests {
    use crate::test_connection::TestConnection;
    use crate::{conn, Client};
    use smithy_http::body::SdkBody;
    use tower::BoxError;

@@ -145,4 +146,13 @@ mod tests {
        }
        let _ = check();
    }

    fn is_send_sync<T: Send + Sync>(_: T) {}

    #[test]
    fn construct_test_client() {
        let test_conn = TestConnection::<String>::new(vec![]);
        let client = Client::new(conn::Standard::new(test_conn));
        is_send_sync(client);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ kms = { path = "../../build/aws-sdk/kms" }
smithy-http = { path = "../../build/aws-sdk/smithy-http" }
smithy-types = { path = "../../build/aws-sdk/smithy-types" }
http = "0.2.3"
aws-hyper = { path = "../../build/aws-sdk/aws-hyper" }
aws-hyper = { path = "../../build/aws-sdk/aws-hyper", features = ["test-util"] }
aws-auth = { path = "../../build/aws-sdk/aws-auth" }
aws-http = { path = "../../build/aws-sdk/aws-http" }
tokio = { version = "1", features = ["full"]}
+12 −7
Original line number Diff line number Diff line
@@ -6,11 +6,12 @@
use aws_auth::Credentials;
use aws_http::user_agent::AwsUserAgent;
use aws_hyper::test_connection::TestConnection;
use aws_hyper::Client;
use aws_hyper::{Client, SdkError};
use http::Uri;
use kms::error::GenerateRandomErrorKind;
use kms::operation::GenerateRandom;
use smithy_http::body::SdkBody;
use kms::{Config, Region};
use smithy_http::body::SdkBody;
use std::time::{Duration, UNIX_EPOCH};

// TODO: having the full HTTP requests right in the code is a bit gross, consider something
@@ -137,13 +138,17 @@ async fn generate_random_keystore_not_found() {
    let client = Client::new(conn.clone());
    let err = client.call(op).await.expect_err("key store doesn't exist");
    let inner = match err {
        aws_hyper::SdkError::ServiceError {
            err: kms::error::GenerateRandomError::CustomKeyStoreNotFoundError(e),
            ..
        } => e,
        SdkError::ServiceError { err, .. } => err,
        other => panic!("Incorrect error received: {:}", other),
    };
    assert_eq!(inner.message, None);
    assert!(matches!(
        inner.kind,
        GenerateRandomErrorKind::CustomKeyStoreNotFoundError(_)
    ));
    assert_eq!(
        inner.request_id(),
        Some("bfe81a0a-9a08-4e71-9910-cdb5ab6ea3b6")
    );
    assert_eq!(conn.requests().len(), 1);
    for validate_request in conn.requests().iter() {
        validate_request.assert_matches(vec![]);
Loading