test(service): fix E0283 in list_games mock tests to unbreak Backend CI - #947
test(service): fix E0283 in list_games mock tests to unbreak Backend CI#947abdulwaarith0 wants to merge 4 commits into
Conversation
The count result set in test_list_games_query_structure and test_list_games_with_cursor was an untyped empty `vec![]`. Under sea-orm 1.1.20 the added IntoMockRow impls make the element type ambiguous, so `append_query_results` fails to compile with E0283 (type annotations needed) — breaking `cargo test` for the whole service module and turning Backend CI red on main and every PR. Type the empty count set as `Vec::<game::Model>::new()` so `T: IntoMockRow` is inferable. Behavior is unchanged: count() on an empty mock result resolves to 0 and execution continues to the data query, so both queries still run (transaction_log.len() == 2). Verified against sea-orm 1.1.20 in isolation.
The ws_integration_test built its target URL as
format!("{}/v1/ws/game/{}", srv.url(""), game_id)
but srv.url("") returns a trailing slash, so the path became
'//v1/ws/game/...' with a double slash, which actix routes to 404. The
four connect-and-expect tests failed the handshake with
InvalidResponseStatus(404); the two negative tests only passed because a
404 still satisfies their is_err() assertion.
Pass the path into srv.url() (which handles the leading slash) instead of
concatenating onto srv.url(""), producing a correct single-slash URL.
Verified against actix-test in isolation: srv.url("") + concat -> 404,
srv.url("/v1/ws/game/x") -> 200. Production route is unaffected; this was
a test-only URL bug that (with the E0283 fix in this PR) unblocks Backend CI.
|
Added a second commit. The E0283 fix (first commit) makes the Root cause (test-only, not production): the tests built their URL as Fix: pass the path into |
… assertion) The final failing ws_integration_test asserted that a client-sent Move produces no response, based on a since-outdated no-op in WsSession's Text handler. That handler now parses the message and broadcasts it to the game (ws.rs), and because the sender is in the game's broadcast set it receives its own move back (version-stamped). The original author anticipated this: 'if this ever starts failing because a response does arrive ... update this test to assert the new behavior.' Rewrite the test to send a Move and assert the version-stamped WsMessage::Move is broadcast back, using the same frame-reading pattern as the other tests. Completes the Backend CI repair in this PR (ws_integration_test now 6/6).
…count query test_list_games_query_structure and test_list_games_with_cursor inspected transaction_log[0], but since the pagination refactor added a COUNT query that runs first, index 0 is the count query — which carries neither the ORDER BY / LIMIT nor the keyset cursor predicate (those are on the data query at index 1). The assertions therefore failed once the E0283 fix in this PR let these tests compile and run. Point both at transaction_log[1]. Verified against sea-orm 1.1.20 in isolation that the data query contains exactly the asserted fragments (WHERE white_player=$1 OR black_player=$2, ORDER BY created_at DESC id DESC, LIMIT $3; and the cursor keyset created_at<$1 OR (created_at=$2 AND id<$3)).
|
Test Backend is green ✅ — the four test-only fixes in this PR (sea-orm mock The remaining red is a separate Security Scan check, and it's not caused by this PR — my diff is test-only (no This fails on |
|
Friendly bump on this one 🙏 — it's been green on Test Backend and mergeable for several days now. Since landing it also unblocks the companion PRs #944 and #946 (they only inherit the old Small correction to my note above for the record: the single |
Summary
cargo testfor theservicemodule currently fails to compile, turning Backend CI red onmainand on every open PR. The error:Root cause
In
test_list_games_query_structureandtest_list_games_with_cursor, the count query's mock result set is an untyped emptyvec![]. Under sea-orm 1.1.20 the additionalIntoMockRowimpls make the element type of an empty vec ambiguous, soappend_query_results::<T, _, _>can no longer inferT. (Introduced when the count query result set was added in the pagination work — the data-query set compiles fine becausegame::Modelpins its type.)Fix
Type the empty count set as
Vec::<game::Model>::new()soT: IntoMockRowis inferable. No behavior change —count()on an empty mock result resolves to0and execution continues to the data query, so both queries still run andtransaction_log.len() == 2still holds.Verification
Built in isolation against sea-orm 1.1.20 (the workspace can't build the full
servicecrate locally due to an unrelated OpenSSL dev-dep). A minimal entity reproducing the exact flow confirms:i.e. the typed empty set compiles,
count()returns 0 without error, and both the count and data queries execute — matching each test's assertions.