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 2 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 |
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.