wip
This commit is contained in:
@@ -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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user