Skip to content

Commit

Permalink
refactor(http/retry): trailers_only() uses Frame<T>
Browse files Browse the repository at this point in the history
see linkerd/linkerd2#8733.

this commit upgrades a test that uses defunct `data()` and `trailers()`
futures.

Signed-off-by: katelyn martin <[email protected]>
  • Loading branch information
cratelyn committed Jan 24, 2025
1 parent 28c80b8 commit cc7adcb
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions linkerd/http/retry/src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,12 @@ mod tests {
async fn trailers_only() {
let Test {
mut tx,
mut initial,
mut replay,
initial,
replay,
_trace,
} = Test::new();
let mut initial = crate::compat::ForwardCompatibleBody::new(initial);
let mut replay = crate::compat::ForwardCompatibleBody::new(replay);

let mut tlrs = HeaderMap::new();
tlrs.insert("x-hello", HeaderValue::from_str("world").unwrap());
Expand All @@ -604,16 +606,26 @@ mod tests {

drop(tx);

assert!(dbg!(initial.data().await).is_none(), "no data in body");
let initial_tlrs = initial.trailers().await.expect("trailers should not error");
assert_eq!(initial_tlrs.as_ref(), Some(&tlrs));
let initial_tlrs = initial
.frame()
.await
.expect("should yield a result")
.expect("should yield a frame")
.into_trailers()
.expect("should yield trailers");
assert_eq!(&initial_tlrs, &tlrs);

// drop the initial body to send the data to the replay
drop(initial);

assert!(dbg!(replay.data().await).is_none(), "no data in body");
let replay_tlrs = replay.trailers().await.expect("trailers should not error");
assert_eq!(replay_tlrs.as_ref(), Some(&tlrs));
let replay_tlrs = replay
.frame()
.await
.expect("should yield a result")
.expect("should yield a frame")
.into_trailers()
.expect("should yield trailers");
assert_eq!(&replay_tlrs, &tlrs);
}

#[tokio::test(flavor = "current_thread")]
Expand Down

0 comments on commit cc7adcb

Please sign in to comment.