fix: ensure archive doctests pass

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-03-01 21:49:32 -06:00
parent 1a6dac03d5
commit 2874d290eb
1 changed files with 18 additions and 4 deletions

View File

@ -74,8 +74,12 @@ impl Archive {
/// # Examples
/// ```
/// # use crate::client::archive::Archive;
/// let archive = Archive::try_default()
/// archive.track_game("/home/user/Documents/generic_company/generic_game/save_folder")
/// let mut archive = Archive::try_default().unwrap();
/// let game_save_path = "/home/user/Documents/generic_company/generic_game/save_folder";
/// match archive.track_game(game_save_path) {
/// Ok(_) => println!("Save Sync is now tracking {}", game_save_path),
/// Err(err) => eprintln!("Failed to track {}: {:?}", game_save_path, err)
/// };
/// ```
pub fn track_game<P: AsRef<Path>>(&mut self, path: P) -> Result<(), GameTrackError> {
let game_save_loc = self.get_game_save_files(path, None)?;
@ -150,7 +154,11 @@ impl Archive {
/// let drop_res = archive.drop_game("/home/user/Documents/generic_company/generic_game/save_folder");
/// ```
pub fn drop_game<P: AsRef<Path>>(&mut self, path: P) -> Result<(), GameDropError> {
unimplemented!()
self.tracked_games
.retain(|game| game.original_path != path.as_ref());
// TODO: Remove backup copy of game save location on disk
Ok(())
}
/// Removes a game from the list of tracked games using the game's friendly name
@ -167,7 +175,13 @@ impl Archive {
/// let drop_res = archive.drop_game("raging_loop");
/// ```
pub fn drop_game_with_friendly(&mut self, name: &str) -> Result<(), GameDropError> {
unimplemented!()
self.tracked_games.retain(|game| match &game.friendly_name {
Some(f_name) => f_name != name,
None => false,
});
// TODO: Remove backup copy of game save location on disk
Ok(())
}
}