Skip to content

Fill in more test coverage#306

Merged
bdeitte merged 5 commits intomainfrom
test-fill-in
Feb 21, 2026
Merged

Fill in more test coverage#306
bdeitte merged 5 commits intomainfrom
test-fill-in

Conversation

@bdeitte
Copy link
Owner

@bdeitte bdeitte commented Feb 21, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 21, 2026 19:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the test suite to cover additional edge cases and previously untested branches across transports, buffering, telemetry, and metric helper APIs.

Changes:

  • Add new/expanded tests for UDP DNS caching behaviors, transport newline handling, and socket-null error paths.
  • Add telemetry, buffering, close(), childClient(), event(), check(), and stats function edge-case coverage.
  • Introduce a new test/constants.js suite covering protocol constants and platform-specific error-code helpers.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/udpDnsCacheTransport.js Adds DNS cache edge-case tests (lookup failure, IP host bypass, TTL re-resolution).
test/transport.js Adds transport-focused tests (null socket path, mock transport event API, TCP/stream newline).
test/telemetry.js Adds tests for no-op flush paths, counter flushing, interval start/stop, and breakdown tags.
test/statsFunctions.js Adds metric API edge cases (negative/zero/large values, floats, Date timing, array stats).
test/send.js Adds send/_send/sendMessage edge-case coverage and mock-mode behavior tests.
test/event.js Adds coverage for empty options and special character escaping.
test/constants.js New test file for constants module behavior.
test/close.js Adds close() edge cases (force close after retries, telemetry-enabled close).
test/childClient.js Adds coverage for inheritance/sharing (socket/buffer), nested children, tag override behavior.
test/check.js Adds coverage for all CHECKS statuses being emitted.
test/buffer.js Adds buffer boundary/interval/encoding edge-case coverage and parent/child buffer sharing.
Comments suppressed due to low confidence (1)

test/send.js:18

  • afterEach now calls closeAll(server, statsd, true, done), which swallows any errors thrown during client/server shutdown. That can hide real failures (e.g., socket close errors) and make this suite pass when it shouldn’t. Suggest keeping allowErrors as false and instead explicitly null out server/statsd (as you already do) for tests that intentionally bypass normal teardown.
  afterEach(done => {
    closeAll(server, statsd, true, done);
    server = null;
    statsd = null;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

test/check.js Outdated
Comment on lines +158 to +173
server.on('metrics', event => {
// TCP may concatenate messages, so check all status matches in the event
const statusMatches = event.match(/_sc\|[^|]+\|(\d)/g);
if (statusMatches) {
statusMatches.forEach(match => {
const status = parseInt(match.charAt(match.length - 1), 10);
const index = expectedStatuses.indexOf(status);
if (index >= 0) {
expectedStatuses.splice(index, 1);
}
});
}
if (expectedStatuses.length === 0) {
done();
}
});
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

This test can call done() more than once: once expectedStatuses is empty, every subsequent metrics event will still satisfy expectedStatuses.length === 0 and re-invoke done(), which fails the test run. Add a guard (e.g., a doneCalled flag) and/or switch to server.once and remove the listener after completion.

Copilot uses AI. Check for mistakes.
@bdeitte bdeitte merged commit b7d9792 into main Feb 21, 2026
13 checks passed
@bdeitte bdeitte deleted the test-fill-in branch February 21, 2026 20:10
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