From 4a5f104df4b310684bf42aafe2a73d1745527f03 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Wed, 19 Jun 2024 18:46:10 +0100 Subject: [PATCH] Improve override plugin tests --- .github/workflows/ci.yml | 2 +- src/plugin.rs | 44 ++++++++++++++++------------------------ 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 524ccac..2eb6883 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: [push, pull_request] env: CARGO_TERM_COLOR: always - TESTING_PLUGINS_VERSION: "1.6.0" + TESTING_PLUGINS_VERSION: "1.6.1" jobs: rustfmt: diff --git a/src/plugin.rs b/src/plugin.rs index cd1aff2..324ec4b 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -1772,13 +1772,13 @@ mod tests { #[test] fn is_light_plugin_should_be_false_for_a_plugin_with_the_override_flag_set_and_an_esl_extension( ) { - let mut plugin = Plugin::new(GameId::Starfield, Path::new("Blank.esl")); - let file_data = &[ - 0x54, 0x45, 0x53, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xB2, 0x2E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, - ]; - plugin.data.header_record = - Record::parse(file_data, GameId::Starfield, true).unwrap().1; + let tmp_dir = tempdir().unwrap(); + + let path = tmp_dir.path().join("Blank.esl"); + copy("testing-plugins/Starfield/Data/Blank - Override.esp", &path).unwrap(); + + let mut plugin = Plugin::new(GameId::Starfield, &path); + plugin.parse_file(true).unwrap(); assert!(!plugin.is_light_plugin()); } @@ -1847,15 +1847,11 @@ mod tests { #[test] fn is_override_plugin_should_be_true_for_a_plugin_with_the_override_flag_set_and_at_least_one_master_and_no_light_flag( ) { - let mut plugin = Plugin::new(GameId::Starfield, Path::new("Blank.esm")); - let file_data = &[ - 0x54, 0x45, 0x53, 0x34, 0x07, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xB2, 0x2E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x41, 0x53, 0x54, - 0x01, 0x00, 0x00, - ]; - plugin.data.header_record = Record::parse(file_data, GameId::Starfield, false) - .unwrap() - .1; + let mut plugin = Plugin::new( + GameId::Starfield, + Path::new("testing-plugins/Starfield/Data/Blank - Override.esp"), + ); + plugin.parse_file(true).unwrap(); assert!(plugin.is_override_plugin()); } @@ -1877,15 +1873,11 @@ mod tests { #[test] fn is_override_plugin_should_be_false_for_a_plugin_with_the_override_and_light_flags_set() { - let mut plugin = Plugin::new(GameId::Starfield, Path::new("Blank.esm")); - let file_data = &[ - 0x54, 0x45, 0x53, 0x34, 0x07, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xB2, 0x2E, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x41, 0x53, 0x54, - 0x01, 0x00, 0x00, - ]; - plugin.data.header_record = Record::parse(file_data, GameId::Starfield, false) - .unwrap() - .1; + let mut plugin = Plugin::new( + GameId::Starfield, + Path::new("testing-plugins/Starfield/Data/Blank - Override.small.esm"), + ); + plugin.parse_file(true).unwrap(); assert!(!plugin.is_override_plugin()); } @@ -1944,7 +1936,7 @@ mod tests { fn is_valid_as_override_plugin_should_be_true_if_the_plugin_has_no_new_records() { let mut plugin = Plugin::new( GameId::Starfield, - Path::new("testing-plugins/SkyrimSE/Data/Blank - Different Plugin Dependent.esp"), + Path::new("testing-plugins/Starfield/Data/Blank - Override.esp"), ); assert!(plugin.parse_file(false).is_ok());