Skip to content

test(service): fix E0283 in list_games mock tests to unbreak Backend CI - #947

Open
abdulwaarith0 wants to merge 2 commits into
OpenKnight-Foundation:mainfrom
abdulwaarith0:fix/games-rs-e0283-mockrow
Open

test(service): fix E0283 in list_games mock tests to unbreak Backend CI#947
abdulwaarith0 wants to merge 2 commits into
OpenKnight-Foundation:mainfrom
abdulwaarith0:fix/games-rs-e0283-mockrow

Conversation

@abdulwaarith0

Copy link
Copy Markdown
Contributor

Summary

cargo test for the service module currently fails to compile, turning Backend CI red on main and on every open PR. The error:

error[E0283]: type annotations needed
  --> modules/service/src/games.rs:616 and :678
     .append_query_results(vec![ vec![] ])
      ^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T`
                                 declared on the method `append_query_results`

Root cause

In test_list_games_query_structure and test_list_games_with_cursor, the count query's mock result set is an untyped empty vec![]. Under sea-orm 1.1.20 the additional IntoMockRow impls make the element type of an empty vec ambiguous, so append_query_results::<T, _, _> can no longer infer T. (Introduced when the count query result set was added in the pagination work — the data-query set compiles fine because game::Model pins its type.)

Fix

Type the empty count set as Vec::<game::Model>::new() so T: IntoMockRow is inferable. No behavior changecount() on an empty mock result resolves to 0 and execution continues to the data query, so both queries still run and transaction_log.len() == 2 still holds.

Verification

Built in isolation against sea-orm 1.1.20 (the workspace can't build the full service crate locally due to an unrelated OpenSSL dev-dep). A minimal entity reproducing the exact flow confirms:

count on empty mock = 0
data rows           = 1
transaction_log.len() = 2

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.

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.
@abdulwaarith0

Copy link
Copy Markdown
Contributor Author

Added a second commit. The E0283 fix (first commit) makes the service module compile again — but that unmasked a separate pre-existing failure it had been hiding: 4 tests in api/tests/ws_integration_test.rs failed the WS handshake with InvalidResponseStatus(404).

Root cause (test-only, not production): the tests built their URL as format!("{}/v1/ws/game/{}", srv.url(""), game_id), but srv.url("") returns a trailing slash → the path became //v1/ws/game/... (double slash) → actix 404. Only the 4 positive tests failed; the 2 negative tests passed for the wrong reason (a 404 still satisfies their is_err() check).

Fix: pass the path into srv.url() (which handles the leading slash) instead of concatenating onto srv.url(""). Verified against actix-test in isolation: concat form → 404, srv.url("/v1/ws/game/x") → 200. Together the two commits should fully green Backend CI.

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