Skip to content

Commit 8949c69

Browse files
committed
refactor: simplify InsertFormatted tests
1 parent 280ff20 commit 8949c69

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

tests/it/insert_formatted.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,13 @@ async fn insert_send_timeout() {
114114
.insert_formatted_with("INSERT INTO nyc_taxi_trips_small FORMAT TabSeparated")
115115
.with_timeouts(Some(send_timeout), None);
116116

117-
// First send actually initiates the request.
118-
if let Err(e) = insert.send(bytes.clone()).await {
119-
assert!(
120-
matches!(e, Error::TimedOut),
121-
"expected `Err(TimedOut)`, got {e:?}"
122-
);
123-
}
124-
125-
// We have to accept the socket
126-
let _socket = listener.accept().await.unwrap();
127-
128117
for _ in 0..1024 {
129-
// It might take a few sends to fill up the TCP send window.
118+
// First send actually initiates the request,
119+
// then it might take a few more sends to fill up the TCP send window.
130120
if let Err(e) = insert.send(bytes.clone()).await {
131121
assert!(
132122
matches!(e, Error::TimedOut),
133-
"expected `Err(TimedOut)`, got {e:?}"
123+
"expected `Error::TimedOut`, got {e:?}"
134124
);
135125
return;
136126
}
@@ -164,15 +154,12 @@ async fn insert_end_timeout() {
164154
);
165155
}
166156

167-
// We have to accept the socket
168-
let _socket = listener.accept().await.unwrap();
157+
let res = insert.end().await;
169158

170-
if let Err(e) = insert.end().await {
171-
assert!(
172-
matches!(e, Error::TimedOut),
173-
"expected `Err(TimedOut)`, got {e:?}"
174-
);
175-
}
159+
assert!(
160+
matches!(res, Err(Error::TimedOut)),
161+
"expected `Err(TimedOut)`, got {res:?}"
162+
);
176163
}
177164

178165
#[tokio::test]

0 commit comments

Comments
 (0)