Skip to content

Commit

Permalink
Alias lastupdated for last_updated (#61)
Browse files Browse the repository at this point in the history
* Add failing test

* Alias `last_updated` to `lastupdated` as well
  • Loading branch information
CosmicHorrorDev authored Dec 23, 2023
1 parent 6c8e433 commit d72ee70
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ pub struct App {
pub launcher_path: Option<PathBuf>,
pub state_flags: Option<StateFlags>,
// 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<time::SystemTime>,
// Can't find anything on what these values mean. I've seen 0, 2, 4, 6, and 7
pub update_result: Option<u64>,
Expand Down
7 changes: 7 additions & 0 deletions src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,11 @@ impl AppFile {
}
}

#[derive(Clone, Copy)]
pub enum SampleApp {
GarrysMod,
GraveyardKeeper,
Resonite,
Warframe,
}

Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pub mod helpers;
mod legacy;
mod temp;
#[cfg(test)]
mod tests;
#[cfg(test)]
mod wasm;

pub type TestError = Box<dyn std::error::Error>;
Expand Down
18 changes: 18 additions & 0 deletions src/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
50 changes: 50 additions & 0 deletions tests/assets/appmanifest_2519830.acf
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit d72ee70

Please sign in to comment.