diff --git a/src/app.rs b/src/app.rs index 3c3ba3c..e557b2a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -66,7 +66,11 @@ pub struct App { pub launcher_path: Option, pub state_flags: Option, // TODO: Need to handle this for serializing too before `App` can `impl Serialize` - #[serde(default, deserialize_with = "de_time_as_secs_from_unix_epoch")] + #[serde( + alias = "lastupdated", + default, + deserialize_with = "de_time_as_secs_from_unix_epoch" + )] pub last_updated: Option, // Can't find anything on what these values mean. I've seen 0, 2, 4, 6, and 7 pub update_result: Option, diff --git a/src/tests/helpers.rs b/src/tests/helpers.rs index 6982956..ce175c5 100644 --- a/src/tests/helpers.rs +++ b/src/tests/helpers.rs @@ -255,9 +255,11 @@ impl AppFile { } } +#[derive(Clone, Copy)] pub enum SampleApp { GarrysMod, GraveyardKeeper, + Resonite, Warframe, } @@ -286,6 +288,11 @@ impl SampleApp { "Graveyard Keeper", include_str!("../../tests/assets/appmanifest_599140.acf"), ), + Self::Resonite => ( + 2_519_830, + "Resonite", + include_str!("../../tests/assets/appmanifest_2519830.acf"), + ), Self::Warframe => ( 230_410, "Warframe", diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 6d036c2..9df106d 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -3,6 +3,8 @@ pub mod helpers; mod legacy; mod temp; #[cfg(test)] +mod tests; +#[cfg(test)] mod wasm; pub type TestError = Box; diff --git a/src/tests/tests.rs b/src/tests/tests.rs new file mode 100644 index 0000000..f98454e --- /dev/null +++ b/src/tests/tests.rs @@ -0,0 +1,18 @@ +use crate::tests::{ + helpers::{SampleApp, TempSteamDir}, + TestResult, +}; + +// Context: https://github.com/WilliamVenner/steamlocate-rs/issues/58 +#[test] +fn app_lastupdated_casing() -> TestResult { + let sample_app = SampleApp::Resonite; + let temp_steam_dir = TempSteamDir::builder().app(sample_app.into()).finish()?; + let steam_dir = temp_steam_dir.steam_dir(); + + let (app, _library) = steam_dir.find_app(sample_app.id())?.unwrap(); + // Last updated _should_ be `Some(_)` for this app even though it uses lowercase casing + let _ = app.last_updated.unwrap(); + + Ok(()) +} diff --git a/tests/assets/appmanifest_2519830.acf b/tests/assets/appmanifest_2519830.acf new file mode 100644 index 0000000..5610c7f --- /dev/null +++ b/tests/assets/appmanifest_2519830.acf @@ -0,0 +1,50 @@ +"AppState" +{ + "appid" "2519830" + "Universe" "1" + "name" "Resonite" + "StateFlags" "4" + "installdir" "Resonite" + "lastupdated" "1702688752" + "SizeOnDisk" "1102323116" + "StagingSize" "0" + "buildid" "12967476" + "LastOwner" "76561198022773299" + "UpdateResult" "0" + "BytesToDownload" "2332576" + "BytesDownloaded" "2332576" + "BytesToStage" "54625540" + "BytesStaged" "54625540" + "TargetBuildID" "12967476" + "AutoUpdateBehavior" "0" + "AllowOtherDownloadsWhileRunning" "0" + "ScheduledAutoUpdate" "0" + "InstalledDepots" + { + "2519832" + { + "manifest" "1396658363472368690" + "size" "514493538" + } + "2519831" + { + "manifest" "5082223756179978205" + "size" "587829578" + } + } + "SharedDepots" + { + "228984" "228980" + "228985" "228980" + "228988" "228980" + "228989" "228980" + } + "UserConfig" + { + "language" "english" + } + "MountedConfig" + { + "language" "english" + } +}