Skip to content

test(nodes): add unit tests for json_serialize, sink, bytes_input, bytes_output, and streaming_utils#504

Merged
streamer45 merged 3 commits into
mainfrom
devin/1779647889-nodes-coverage-tier2
May 25, 2026
Merged

test(nodes): add unit tests for json_serialize, sink, bytes_input, bytes_output, and streaming_utils#504
streamer45 merged 3 commits into
mainfrom
devin/1779647889-nodes-coverage-tier2

Conversation

@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor

@staging-devin-ai-integration staging-devin-ai-integration Bot commented May 24, 2026

Summary

  • Add unit tests for five zero-coverage files in crates/nodes/: json_serialize, sink, bytes_input, bytes_output, and streaming_utils.
  • Tests cover construction, pin shapes, config parsing, and runtime behaviour (packet flow, state transitions, cancellation, EOF handling).
  • Test-only PR — no production code changes.

Review & Validation

  • cargo test -p streamkit-nodes passes (36 new tests)
  • just lint clean

Link to Devin session: https://staging.itsdev.in/sessions/8ef5ea42a4a742749127948ba9ce3d31
Requested by: @streamer45


Devin Review

Status Commit
🕐 Outdated 699ba97 (HEAD is 6e24f0f)

Run Devin Review

Open in Devin Review (Staging)

…tes_output, and streaming_utils

Signed-off-by: streamkit-devin <devin@streamkit.dev>
@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Copy link
Copy Markdown
Contributor Author

@staging-devin-ai-integration staging-devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 7 potential issues.

Open in Devin Review (Staging)
Debug

Playground

Comment thread crates/nodes/src/core/bytes_input.rs Outdated
}

#[cfg(test)]
#[allow(clippy::unwrap_used, clippy::expect_used)]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🔴 Lint suppression lacks the required rationale

AGENTS.md requires every lint suppression to include a comment explaining the rationale (AGENTS.md:54-56), but this newly added #[allow(clippy::unwrap_used, clippy::expect_used)] has no rationale. This violates the repository's mandatory linting discipline for PR changes.

Suggested change
#[allow(clippy::unwrap_used, clippy::expect_used)]
#[allow(clippy::unwrap_used, clippy::expect_used)] // Test assertions use unwrap/expect to fail loudly.
Open in Devin Review (Staging)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — added rationale comment in b866884.

Comment thread crates/nodes/src/core/bytes_output.rs Outdated
}

#[cfg(test)]
#[allow(clippy::unwrap_used, clippy::expect_used)]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🔴 Lint suppression lacks the required rationale

AGENTS.md requires every lint suppression to include a comment explaining the rationale (AGENTS.md:54-56), but this newly added #[allow(clippy::unwrap_used, clippy::expect_used)] has no rationale. This violates the repository's mandatory linting discipline for PR changes.

Suggested change
#[allow(clippy::unwrap_used, clippy::expect_used)]
#[allow(clippy::unwrap_used, clippy::expect_used)] // Test assertions use unwrap/expect to fail loudly.
Open in Devin Review (Staging)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — added rationale comment in b866884.

Comment thread crates/nodes/src/core/json_serialize.rs Outdated
}

#[cfg(test)]
#[allow(clippy::unwrap_used, clippy::expect_used)]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🔴 Lint suppression lacks the required rationale

AGENTS.md requires every lint suppression to include a comment explaining the rationale (AGENTS.md:54-56), but this newly added #[allow(clippy::unwrap_used, clippy::expect_used)] has no rationale. This violates the repository's mandatory linting discipline for PR changes.

Suggested change
#[allow(clippy::unwrap_used, clippy::expect_used)]
#[allow(clippy::unwrap_used, clippy::expect_used)] // Test assertions use unwrap/expect to fail loudly.
Open in Devin Review (Staging)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — added rationale comment in b866884.

Comment thread crates/nodes/src/core/sink.rs Outdated
}

#[cfg(test)]
#[allow(clippy::unwrap_used, clippy::expect_used)]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🔴 Lint suppression lacks the required rationale

AGENTS.md requires every lint suppression to include a comment explaining the rationale (AGENTS.md:54-56), but this newly added #[allow(clippy::unwrap_used, clippy::expect_used)] has no rationale. This violates the repository's mandatory linting discipline for PR changes.

Suggested change
#[allow(clippy::unwrap_used, clippy::expect_used)]
#[allow(clippy::unwrap_used, clippy::expect_used)] // Test assertions use unwrap/expect to fail loudly.
Open in Devin Review (Staging)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — added rationale comment in b866884.

Comment thread crates/nodes/src/streaming_utils.rs Outdated
}

#[cfg(test)]
#[allow(clippy::unwrap_used, clippy::expect_used)]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🔴 Lint suppression lacks the required rationale

AGENTS.md requires every lint suppression to include a comment explaining the rationale (AGENTS.md:54-56), but this newly added #[allow(clippy::unwrap_used, clippy::expect_used)] has no rationale. This violates the repository's mandatory linting discipline for PR changes.

Suggested change
#[allow(clippy::unwrap_used, clippy::expect_used)]
#[allow(clippy::unwrap_used, clippy::expect_used)] // Test assertions use unwrap/expect to fail loudly.
Open in Devin Review (Staging)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed — added rationale comment in b866884.

Comment on lines +140 to +146
#[test]
fn new_with_config_ignores_unknown_fields() {
let (tx, _rx) = mpsc::channel(10);
let params = serde_json::json!({"unknown": 42});
let node = BytesOutputNode::new_with_config(tx, Some(&params)).unwrap();
assert!(node.configured_content_type().is_none());
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

📝 Info: Unknown-field config tests document fallback behavior, not strict validation

These newly added tests may look surprising because the config structs use #[serde(deny_unknown_fields)], but BytesOutputNode::new_with_config calls config_helpers::parse_config_optional, whose implementation returns unwrap_or_default() on any deserialization failure (crates/core/src/helpers.rs:25-30). That means an unknown field causes the entire optional config to fall back to defaults instead of returning an error, so the test expectation matches existing shared helper semantics rather than being a new functional bug. If strict unknown-field rejection is desired for these nodes, the root behavior is the shared helper/constructor contract rather than these tests alone.

Open in Devin Review (Staging)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Comment on lines +168 to +184
#[tokio::test]
async fn run_serializes_text_to_json_binary() {
let (input_tx, input_rx) = mpsc::channel(10);
let mut inputs = HashMap::new();
inputs.insert("in".to_string(), input_rx);
let (context, mock_sender, mut state_rx) = create_test_context(inputs, 10);

let node = JsonSerialize::new(None).unwrap();
let handle = tokio::spawn(async move { Box::new(node).run(context).await });

assert_state_running(&mut state_rx).await;

input_tx.send(Packet::Text("hello".into())).await.unwrap();
drop(input_tx);

assert_state_stopped(&mut state_rx).await;
handle.await.unwrap().unwrap();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

📝 Info: JsonSerialize uses running/stopped state only, matching pre-existing behavior

The new tests for JsonSerialize wait for Running and Stopped but not Initializing. I checked the implementation and it emits only state_helpers::emit_running at startup and emit_stopped at exit (crates/nodes/src/core/json_serialize.rs:67-106), so this is an intentional reflection of the node's current state lifecycle rather than a missing assertion in the tests. Any desire to standardize lifecycle events across nodes would be a broader consistency change outside this PR's added tests.

Open in Devin Review (Staging)

Was this helpful? React with 👍 or 👎 to provide feedback.

Debug

Playground

Signed-off-by: streamkit-devin <devin@streamkit.dev>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

❌ Patch coverage is 99.28910% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.27%. Comparing base (719d22e) to head (6e24f0f).

Files with missing lines Patch % Lines
crates/nodes/src/core/json_serialize.rs 97.45% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #504      +/-   ##
==========================================
+ Coverage   78.10%   78.27%   +0.17%     
==========================================
  Files         232      232              
  Lines       65234    65656     +422     
  Branches     1909     1909              
==========================================
+ Hits        50948    51393     +445     
+ Misses      14280    14257      -23     
  Partials        6        6              
Flag Coverage Δ
backend 77.88% <99.28%> (+0.19%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 85.27% <ø> (ø)
engine 83.68% <ø> (ø)
api 89.98% <ø> (ø)
nodes 72.04% <99.28%> (+0.60%) ⬆️
server 80.26% <ø> (ø)
plugin-native 83.47% <ø> (ø)
plugin-wasm 91.90% <ø> (ø)
ui-services 84.67% <ø> (ø)
ui-components 60.49% <ø> (ø)
Files with missing lines Coverage Δ
crates/nodes/src/core/bytes_input.rs 97.61% <100.00%> (+20.19%) ⬆️
crates/nodes/src/core/bytes_output.rs 100.00% <100.00%> (+12.00%) ⬆️
crates/nodes/src/core/sink.rs 100.00% <100.00%> (+7.40%) ⬆️
crates/nodes/src/streaming_utils.rs 96.24% <100.00%> (+15.59%) ⬆️
crates/nodes/src/core/json_serialize.rs 91.83% <97.45%> (+43.56%) ⬆️

... and 1 file 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.

@streamer45 streamer45 merged commit fb752f2 into main May 25, 2026
29 checks passed
@streamer45 streamer45 deleted the devin/1779647889-nodes-coverage-tier2 branch May 25, 2026 13:26
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