Skip to content

Refactor/isolate websocket tests#1091

Merged
gittiver merged 5 commits into
CrowCpp:masterfrom
nicholashanson:refactor/isolate_websocket_tests
Sep 21, 2025
Merged

Refactor/isolate websocket tests#1091
gittiver merged 5 commits into
CrowCpp:masterfrom
nicholashanson:refactor/isolate_websocket_tests

Conversation

@nicholashanson

Copy link
Copy Markdown
Contributor

Refactored websocket unit tests from unittest.cpp into unit_tests/test_websocket.cpp

Also made the following small changed:

  • Changed one-line http_message string:
    static std::string http_message = "GET /ws HTTP/1.1\r\nConnection: keep-alive, Upgrade\r\nupgrade:...
    
    into multi-line string:
        static std::string http_message = 
          "GET /ws HTTP/1.1\r\n"
          "Connection: keep-alive, Upgrade\r\n"
          "upgrade: websocket\r\n"
          "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n"
          "Sec-WebSocket-Version: 13\r\n"
          "Host: localhost\r\n"
          "\r\n";
    
  • Added "[websocket]" tag to websocket unit tests so they can be run in isolation.

Before refactor:

Filters: "websocket","websocket_close","websocket_missing_host","websocket_max_payload","websocket_subprotocols","mirror_websocket_subprotocols"
Randomness seeded to: 3072039813
(2025-09-15 22:39:02) [INFO    ] Crow/master server is running at http://127.0.0.1:45451 using 2 threads
...
(2025-09-15 22:39:02) [INFO    ] Closing main IO service (0x7087d0005e88)
(2025-09-15 22:39:02) [DEBUG   ] Connection (0x7087c80043c0) freed, total: 0
(2025-09-15 22:39:02) [INFO    ] Exiting.
===============================================================================
All tests passed (69 assertions in 6 test cases)

After refactor:

Filters: [websocket]
Randomness seeded to: 3659788270
(2025-09-15 22:41:06) [INFO    ] Crow/master server is running at http://127.0.0.1:45471 using 2 threads
...
(2025-09-15 22:41:06) [INFO    ] Closing main IO service (0x7144180051b8)
(2025-09-15 22:41:06) [DEBUG   ] Connection (0x714410005730) freed, total: 0
(2025-09-15 22:41:06) [INFO    ] Exiting.
===============================================================================
All tests passed (69 assertions in 6 test cases)

- Moved tests that depend solely on `crow::response` from unittest.cpp
  to tests/unit_tests/test_http_response.cpp for clearer separation of concerns.
- Renamed the original "simple_response_routing_params" test in
  unittest.cpp to "routing_params" to reflect this chage.
- Updated CMakeLists.txt to automatically include all sources under unit_tests/.
Isolated unit tests that depend only on the utility module into test_utility.cpp.

@gittiver gittiver left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please replace globbing by explicit file listing

Comment thread tests/CMakeLists.txt Outdated
@gittiver
gittiver force-pushed the refactor/isolate_websocket_tests branch from 9ca3e49 to f9d8802 Compare September 21, 2025 17:25
gittiver
gittiver previously approved these changes Sep 21, 2025
@gittiver
gittiver merged commit 3ceeb5d into CrowCpp:master Sep 21, 2025
19 checks passed
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