Skip to content

tests: dedup shared fixtures into test_utils::helpers (#907) - #954

Merged
wboayue merged 2 commits into
mainfrom
907-test-fixture-dedup
Oct 5, 2026
Merged

wboayue merged 2 commits into
mainfrom
907-test-fixture-dedup

Conversation

@wboayue

@wboayue wboayue commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Closes #907. Covers the issue body plus the items from @tradatious's comment.

Moved to common::test_utils::helpers:

  • binary_text (4 copies) and body (2), with body now built on binary_text; 2 hand-written frames in connection/common_tests.rs switched to binary_text
  • handshake_response_frame(server_version, zone): replaces 13 hand-written handshake strings across client/connection/transport tests
  • handshake_frames(server_version, zone, next_order_id): the client tests' handshake_frames() and the connection tests' push_handshake_in_zone now share it. push_handshake* stay per file because sync and async MemoryStream are different types.
  • FARM_OK_MSG, farm_ok_frame_unrouted, farm_ok_frame_42
  • execution_data_frame: replaces the hand-built execution_data_body proto with the execution_data() builder
  • NoticeTestData, CapturingSink (adds a notices() snapshot accessor)
  • test_notice(code, msg): replaces 5 constructors (test_notice ×3, make_notice, notice_with_code). It delegates to Notice::synthesized but keeps a separate name, so tests that use real TWS codes don't read like tests of client-generated notices.

Not changed:

  • the protobuf frame in test_parse_raw_message_protobuf: its payload is raw proto bytes, not text, and the test checks the raw protobuf parse path
  • DeclaresTickPrice: each copy is paired with its own static CALL_COUNT counter inside the test. With --all-features, the sync and async tests run in parallel in one binary, so a shared counter would race.

Test-only. Ran clippy --all-targets -D warnings and cargo test --lib for default, --features sync and --all-features, plus cargo fmt --check.

Move duplicated test fixtures to common::test_utils::helpers: binary_text,
body, handshake_frames, FARM_OK_MSG + farm_ok_frame_{42,unrouted},
execution_data_frame (wraps execution_data() builder), NoticeTestData,
CapturingSink, test_notice.
…mes (#907)

- add handshake_response_frame; replace 13 hand-rolled handshake literals,
  full sequences in transport tests use handshake_frames
- client tests: local default_handshake_frames wrapper; vec! literals
- connection/client: TEST_ACCOUNT / TEST_ORDER_ID_SEED over literals
- messages/tests: shorten helpers:: paths
- doc CapturingSink::last/count
@wboayue
wboayue merged commit f1f5dc9 into main Oct 5, 2026
7 checks passed
@wboayue
wboayue deleted the 907-test-fixture-dedup branch October 5, 2026 04:12
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.

Deduplicate test fixtures: body(), CapturingSink, notice constructors

1 participant