test(host): name the catalog-card fixture instead of a six-tuple
clippy::type_complexity, and the struct reads better at the call site: the fixture rows now say which field is the subtype and which is the art id.
This commit is contained in:
@@ -2442,18 +2442,30 @@ fn incomplete_consumable_definitions_are_dropped_not_drawn_wrong() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// One catalogued card for [`club_resolver`]: the FIFA facts the production
|
||||||
|
/// classification path reads.
|
||||||
|
struct CatalogCard {
|
||||||
|
card_id: &'static str,
|
||||||
|
asset_id: u32,
|
||||||
|
kind: &'static str,
|
||||||
|
subtype: i64,
|
||||||
|
card_asset_id: u32,
|
||||||
|
team_id: Option<i64>,
|
||||||
|
}
|
||||||
|
|
||||||
/// A resolver over a catalog that states each card's KIND, so club families flow
|
/// A resolver over a catalog that states each card's KIND, so club families flow
|
||||||
/// through exactly the production classification path (catalog kind -> shaper),
|
/// through exactly the production classification path (catalog kind -> shaper),
|
||||||
/// not a test-only stub.
|
/// not a test-only stub.
|
||||||
fn club_resolver(
|
fn club_resolver(cards: &[CatalogCard]) -> Arc<Fifa17IdentityResolver> {
|
||||||
cards: &[(&str, u32, &str, i64, u32, Option<i64>)],
|
|
||||||
) -> Arc<Fifa17IdentityResolver> {
|
|
||||||
let entries: Vec<String> = cards
|
let entries: Vec<String> = cards
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(id, asset, kind, subtype, art, team)| {
|
.map(|c| {
|
||||||
let team = team
|
let team = c
|
||||||
|
.team_id
|
||||||
.map(|t| format!(",\"team_id\":{t}"))
|
.map(|t| format!(",\"team_id\":{t}"))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
let (id, asset, kind) = (c.card_id, c.asset_id, c.kind);
|
||||||
|
let (subtype, art) = (c.subtype, c.card_asset_id);
|
||||||
format!(
|
format!(
|
||||||
"\"{id}\":{{\"asset_id\":{asset},\"kind\":\"{kind}\",\"subtype\":{subtype},\
|
"\"{id}\":{{\"asset_id\":{asset},\"kind\":\"{kind}\",\"subtype\":{subtype},\
|
||||||
\"card_asset_id\":{art}{team}}}"
|
\"card_asset_id\":{art}{team}}}"
|
||||||
@@ -2478,19 +2490,28 @@ fn club_resolver(
|
|||||||
/// here: an empty result must not be an accident of a missing asset id.
|
/// here: an empty result must not be an accident of a missing asset id.
|
||||||
#[test]
|
#[test]
|
||||||
fn every_ownable_class_projects_on_its_own_arm() {
|
fn every_ownable_class_projects_on_its_own_arm() {
|
||||||
let cards: Vec<(&str, u32, &str, i64, u32, Option<i64>)> = vec![
|
let card = |card_id, asset_id, kind, subtype, card_asset_id, team_id| CatalogCard {
|
||||||
("c_player", 20801, "player", 0, 0, None),
|
card_id,
|
||||||
("c_manager", 1_000_509, "manager", 4, 0, None),
|
asset_id,
|
||||||
("c_coach", 3_000_083, "staff", 8, 0, None),
|
kind,
|
||||||
("c_kit", 6_300_006, "kit", 9, 35, Some(21)),
|
subtype,
|
||||||
("c_badge", 6_000_005, "badge", 11, 39, Some(21)),
|
card_asset_id,
|
||||||
("c_stadium", 6_200_000, "stadium", 10, 36, None),
|
team_id,
|
||||||
("c_ball", 8_120_194, "ball", 30, 37, None),
|
};
|
||||||
("c_logo", 8_010_015, "misc", 31, 40, None),
|
let cards = vec![
|
||||||
|
card("c_player", 20801, "player", 0, 0, None),
|
||||||
|
card("c_manager", 1_000_509, "manager", 4, 0, None),
|
||||||
|
card("c_coach", 3_000_083, "staff", 8, 0, None),
|
||||||
|
card("c_kit", 6_300_006, "kit", 9, 35, Some(21)),
|
||||||
|
card("c_badge", 6_000_005, "badge", 11, 39, Some(21)),
|
||||||
|
card("c_stadium", 6_200_000, "stadium", 10, 36, None),
|
||||||
|
card("c_ball", 8_120_194, "ball", 30, 37, None),
|
||||||
|
card("c_logo", 8_010_015, "misc", 31, 40, None),
|
||||||
];
|
];
|
||||||
let owned: Vec<CoreOwnedItem> = cards
|
let owned: Vec<CoreOwnedItem> = cards
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(id, ..)| {
|
.map(|c| {
|
||||||
|
let id = c.card_id;
|
||||||
item(
|
item(
|
||||||
&format!("oc_{id}"),
|
&format!("oc_{id}"),
|
||||||
id,
|
id,
|
||||||
|
|||||||
Reference in New Issue
Block a user