Skip to content

Commit

Permalink
Improve override plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ortham committed Jun 19, 2024
1 parent a9a5c7b commit 4a5f104
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
44 changes: 18 additions & 26 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand Down Expand Up @@ -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());

Expand Down

0 comments on commit 4a5f104

Please sign in to comment.