Skip to content

Commit

Permalink
Remove derived traits from `aws_smithy_async::future::timeout::TimedO…
Browse files Browse the repository at this point in the history
…utError`
  • Loading branch information
jdisanti committed Oct 22, 2022
1 parent 4b9c07e commit dff97c4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions rust-runtime/aws-smithy-async/src/future/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use std::pin::Pin;
use std::task::{Context, Poll};

/// Error returned when [`Timeout`] times out
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[derive(Debug)]
pub struct TimedOutError;

impl Error for TimedOutError {}
Expand Down Expand Up @@ -106,28 +106,31 @@ mod tests {

#[tokio::test]
async fn success() {
assert_eq!(
Ok(Ok(5)),
Timeout::new(async { Ok::<isize, isize>(5) }, Never).await
);
assert!(matches!(
Timeout::new(async { Ok::<isize, isize>(5) }, Never).await,
Ok(Ok(5))
));
}

#[tokio::test]
async fn failure() {
assert_eq!(
Ok(Err(0)),
Timeout::new(async { Err::<isize, isize>(0) }, Never).await
);
assert!(matches!(
Timeout::new(async { Err::<isize, isize>(0) }, Never).await,
Ok(Err(0))
));
}

#[tokio::test]
async fn timeout() {
assert_eq!(Err(TimedOutError), Timeout::new(Never, async {}).await);
assert!(matches!(
Timeout::new(Never, async {}).await,
Err(TimedOutError)
));
}

// If the value is available at the same time as the timeout, then return the value
#[tokio::test]
async fn prefer_value_to_timeout() {
assert_eq!(Ok(5), Timeout::new(async { 5 }, async {}).await);
assert!(matches!(Timeout::new(async { 5 }, async {}).await, Ok(5)));
}
}

0 comments on commit dff97c4

Please sign in to comment.