hubcio commented on code in PR #3202:
URL: https://github.com/apache/iggy/pull/3202#discussion_r3169252472
##########
core/sdk/src/tcp/tcp_client.rs:
##########
@@ -884,4 +901,32 @@ mod tests {
IggyDuration::from_str("5s").unwrap()
);
}
+
+ #[tokio::test]
+ async fn should_return_error_when_status_is_non_zero() {
+ let mut stream = make_dummy_stream(&[1u8; 10]).await;
+ let tcp_client = TcpClient::handle_response(1, 0, &mut stream).await;
+ assert!(tcp_client.is_err());
+ }
+
+ #[tokio::test]
+ async fn should_return_ok_when_status_is_zero() {
+ let mut stream = make_dummy_stream(&[1u8; 10]).await;
+ let tcp_client = TcpClient::handle_response(0, 0, &mut stream).await;
+ assert!(tcp_client.is_ok());
+ }
+
+ #[tokio::test]
+ async fn should_return_ok_when_length_is_less_than_data() {
+ let mut stream = make_dummy_stream(&[1u8; 10]).await;
+ let tcp_client = TcpClient::handle_response(0, 5, &mut stream).await;
+ assert!(tcp_client.is_ok());
Review Comment:
missing `length == 1` boundary. guard is `if length <= 1`. tests cover 0 and
5; 1 is the inclusive edge, off-by-one risk if guard becomes `<`. add
`handle_response(0, 1, ...) == Ok(Bytes::new())`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]