Skip to content

test(sdk): validate handle_response status and length edge cases#3202

Open
ankushT369 wants to merge 1 commit intoapache:masterfrom
ankushT369:unit_test_tcp_client
Open

test(sdk): validate handle_response status and length edge cases#3202
ankushT369 wants to merge 1 commit intoapache:masterfrom
ankushT369:unit_test_tcp_client

Conversation

@ankushT369
Copy link
Copy Markdown

@ankushT369 ankushT369 commented Apr 30, 2026

Rationale

Tests for handle_response did not cover important edge cases around status codes and response length, leaving potential failure scenarios unverified.

What changed?

handle_response behavior was not validated for error conditions such as non-zero status codes or when the declared response length exceeds available data.

Added unit tests covering both success and failure paths, including boundary conditions for status and length handling.

AI Usage

None

@ankushT369
Copy link
Copy Markdown
Author

@hubcio Hi can you please review this ?

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 72.97297% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.57%. Comparing base (611fca0) to head (c5c2c13).

Files with missing lines Patch % Lines
core/sdk/src/tcp/tcp_client.rs 72.97% 10 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             master    #3202       +/-   ##
=============================================
- Coverage     74.10%   53.57%   -20.53%     
  Complexity      943      943               
=============================================
  Files          1159     1158        -1     
  Lines        102033    93556     -8477     
  Branches      79083    70623     -8460     
=============================================
- Hits          75607    50125    -25482     
- Misses        23765    40974    +17209     
+ Partials       2661     2457      -204     
Components Coverage Δ
Rust Core 47.94% <72.97%> (-27.39%) ⬇️
Java SDK 60.14% <ø> (ø)
C# SDK 69.07% <ø> (-0.31%) ⬇️
Python SDK 81.43% <ø> (ø)
Node SDK 91.53% <ø> (ø)
Go SDK 39.43% <ø> (ø)
Files with missing lines Coverage Δ
core/sdk/src/tcp/tcp_client.rs 56.03% <72.97%> (-15.43%) ⬇️

... and 377 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()).

Add tests to ensure handle_response returns errors for non-zero status
codes and when declared length exceeds available data. Also verify
successful responses for valid status and bounded lengths.

test(sdk): validate handle_response status and length edge cases
@ankushT369 ankushT369 force-pushed the unit_test_tcp_client branch from 66d9ea9 to c5c2c13 Compare April 30, 2026 17:18
@ankushT369
Copy link
Copy Markdown
Author

ankushT369 commented Apr 30, 2026

@hubcio Hey I didnt get the Check status failing in the previous commit

@ankushT369 ankushT369 changed the title test(client): validate handle_response status and length edge cases test(sdk): validate handle_response status and length edge cases May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants