From 132f784d58b503a500076d62cd5ea9535711e299 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Tue, 17 Mar 2026 14:28:43 +0100 Subject: [PATCH] added integration test for Game & export_link on Game --- tests/game_test.rs | 27 +++++++++++++++++++++++++++ tests/root_config_test.rs | 7 +++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/game_test.rs diff --git a/tests/game_test.rs b/tests/game_test.rs new file mode 100644 index 0000000..073d541 --- /dev/null +++ b/tests/game_test.rs @@ -0,0 +1,27 @@ +use std::path::PathBuf; + +use fomod_manager::types::RootConfig; + +fn get_parent() -> PathBuf { + PathBuf::from(file!()).parent().unwrap().to_owned() +} + +fn load_root() -> RootConfig { + RootConfig::load_from_file(get_parent().join("data/root_config_complex.toml")).unwrap() +} + +#[test] +fn export_gamefiles() { + let root_config = load_root(); + + let game = root_config.game_by_id("sse").expect("No game found"); + + let links = game.export_links().expect("Failed to export game links"); + + assert!( + links.iter().all(|e| e.src().is_absolute()), + "Link src is not absolute" + ); + + assert_eq!(links.len(), 4, "Not all files linked"); +} diff --git a/tests/root_config_test.rs b/tests/root_config_test.rs index 91e0858..373cdb4 100644 --- a/tests/root_config_test.rs +++ b/tests/root_config_test.rs @@ -39,6 +39,13 @@ fn parse_complex() { "Installed game wrong path" ); + assert!( + config + .game_by_id("sse") + .is_some_and(|e| e.install_location().is_absolute()), + "Relative game path was not resolved to absolute" + ); + assert!( config .game_by_id("sse")