This commit is contained in:
2025-11-13 23:42:12 +01:00
parent e19eda7919
commit a1dfc5cc89
2 changed files with 66 additions and 24 deletions
+35
View File
@@ -58,6 +58,7 @@ pub struct Game {
#[serde(default)]
pub downloaded: bool,
/// only relevant for client (yeah... I know)
#[serde(default)]
pub installed: bool,
/// ETI game version from version.ini (YYYYMMDD format) (server)
pub eti_game_version: Option<String>,
@@ -214,3 +215,37 @@ impl fmt::Debug for GameFileDescription {
)
}
}
#[cfg(test)]
mod tests {
use serde_json::json;
use super::Game;
#[test]
fn installed_defaults_to_false_when_missing() {
let raw = json!({
"id": "aoe2",
"name": "Age of Empires II",
"description": "desc",
"release_year": "1999",
"publisher": "Microsoft",
"max_players": 8,
"version": "1.0",
"genre": "RTS",
"size": 123456,
"thumbnail": null,
"downloaded": true,
"eti_game_version": "20240101",
"local_version": null,
"peer_count": 2
})
.to_string();
let game: Game = serde_json::from_str(&raw).expect("game should deserialize");
assert!(
!game.installed,
"missing installed flag should default to false"
);
}
}