Skip to content

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

Open
abdulwaarith0 wants to merge 1 commit 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 1 commit 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.
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