Skip to content

test(core,websocket): add unit tests for 8 messaging and WebSocket modules#970

Merged
kcenon merged 4 commits intodevelopfrom
feat/issue-966-add-core-messaging-websocket-tests
Apr 15, 2026
Merged

test(core,websocket): add unit tests for 8 messaging and WebSocket modules#970
kcenon merged 4 commits intodevelopfrom
feat/issue-966-add-core-messaging-websocket-tests

Conversation

@kcenon
Copy link
Copy Markdown
Owner

@kcenon kcenon commented Apr 15, 2026

What

Summary

Add dedicated unit tests for 8 previously untested modules: core messaging (6) and WebSocket (2). Second sub-issue of epic #953.

Change Type

  • Test

Affected Components

  • tests/unit/ — 8 new test files (1,074 lines)
  • tests/CMakeLists.txt — 8 new test targets + add_network_test() macro

Why

Problem Solved

Core messaging and WebSocket modules had zero dedicated unit test coverage despite being primary user-facing networking APIs.

Related Issues

Where

New Test Files

Core Messaging (6 files):

  • messaging_client_test.cpp — TCP client: construction, error paths, callbacks
  • messaging_server_test.cpp — TCP server: construction, callbacks, stop
  • messaging_udp_client_test.cpp — UDP client: construction, send errors, target errors
  • messaging_udp_server_test.cpp — UDP server: construction, callbacks
  • secure_messaging_udp_client_test.cpp — DTLS client: verify flag, callbacks, error paths
  • secure_messaging_udp_server_test.cpp — DTLS server: cert config, callbacks

WebSocket (2 files):

  • messaging_ws_client_test.cpp — config defaults, send/close errors, callbacks
  • messaging_ws_server_test.cpp — config defaults, connection management, broadcast

How

Implementation Details

  • Introduced add_network_test() CMake macro to eliminate boilerplate (~30 lines per target)
  • All tests focus on construction, state management, error paths, and callback registration
  • No network I/O required — tests verify behavior without real connections

Testing Done

  • Full build verification (CMake not available locally — relies on CI)

Breaking Changes

None — new test files only

…dules

Add dedicated unit tests for core messaging (6 modules) and WebSocket
(2 modules) as part of the test coverage expansion effort (epic #953).

Core messaging tests (6 files):
- messaging_client_test: construction, error paths, callbacks
- messaging_server_test: construction, callbacks, stop behavior
- messaging_udp_client_test: construction, send errors, target errors
- messaging_udp_server_test: construction, callbacks, stop behavior
- secure_messaging_udp_client_test: DTLS construction, verify flag, callbacks
- secure_messaging_udp_server_test: DTLS construction, cert config, callbacks

WebSocket tests (2 files):
- messaging_ws_client_test: config defaults, send errors, callbacks
- messaging_ws_server_test: config defaults, connection mgmt, broadcast

Also introduces add_network_test() CMake macro to reduce boilerplate.

Closes #966
kcenon added 3 commits April 15, 2026 12:32
WebSocket client/server tests already exist as test_messaging_ws_client.cpp
and test_messaging_ws_server.cpp in the root tests/ directory. Remove
duplicate test files and CMake entries to fix target name conflicts.
The UDP client/server classes inherit set_receive_callback from both
their own interface and i_udp_client/i_udp_server, making nullptr
calls ambiguous. Remove the null callback tests for these modules.
secure_messaging_udp_client/server depend on dtls_socket symbols from
libs/network-udp which are not available when linking only against the
main network_system library. Remove tests to fix Ubuntu linker failures.
@kcenon kcenon merged commit 1e810a6 into develop Apr 15, 2026
13 checks passed
@kcenon kcenon deleted the feat/issue-966-add-core-messaging-websocket-tests branch April 15, 2026 04:51
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.

1 participant