diff --git a/tests/add_mod_test.rs b/tests/add_mod_test.rs index ef135c2..e09fe4e 100644 --- a/tests/add_mod_test.rs +++ b/tests/add_mod_test.rs @@ -14,10 +14,12 @@ fn load_root() -> RootConfig { } #[test] -fn add_simple_mod() -> Result<(), Box> { +fn add_plain() -> Result<(), Box> { let root_config = load_root(); let mut instance = root_config.load_instance_by_id("instance_minimal")?; - let mod_to_install = root_config.mod_by_id("add_test_1").expect("Mod not found"); + let mod_to_install = root_config + .mod_by_id("add_test_plain") + .expect("Mod not found"); let files_to_add = files_to_install_mod(&root_config, &instance, &mod_to_install)?; insert_mod_to_instance(&mut instance, &mod_to_install, &files_to_add, 0)?; @@ -28,7 +30,7 @@ fn add_simple_mod() -> Result<(), Box> { let the_mod = installed_mods.first().expect("Asserted before"); - assert_eq!(the_mod.mod_id(), "add_test_1"); + assert_eq!(the_mod.mod_id(), "add_test_plain"); assert_eq!(the_mod.priority(), 0); let expected_files: HashSet<_> = [Link::new("plugin.esp", "Data/plugin.esp")] @@ -43,3 +45,100 @@ fn add_simple_mod() -> Result<(), Box> { Ok(()) } + +#[test] +fn add_nested() -> Result<(), Box> { + let root_config = load_root(); + let mut instance = root_config.load_instance_by_id("instance_minimal")?; + let mod_to_install = root_config + .mod_by_id("add_test_nested") + .expect("Mod not found"); + let files_to_add = files_to_install_mod(&root_config, &instance, &mod_to_install)?; + + insert_mod_to_instance(&mut instance, &mod_to_install, &files_to_add, 0)?; + + let installed_mods = instance.mods(); + + assert_eq!(installed_mods.len(), 1); + + let the_mod = installed_mods.first().expect("Asserted before"); + + assert_eq!(the_mod.mod_id(), "add_test_nested"); + assert_eq!(the_mod.priority(), 0); + + let expected_files: HashSet<_> = [Link::new("Data/plugin.esp", "Data/plugin.esp")] + .into_iter() + .collect(); + + assert_eq!( + *the_mod.files(), + expected_files, + "Installed files missmatch" + ); + + Ok(()) +} + +#[test] +fn add_root() -> Result<(), Box> { + let root_config = load_root(); + let mut instance = root_config.load_instance_by_id("instance_minimal")?; + let mod_to_install = root_config + .mod_by_id("add_test_root") + .expect("Mod not found"); + let files_to_add = files_to_install_mod(&root_config, &instance, &mod_to_install)?; + + insert_mod_to_instance(&mut instance, &mod_to_install, &files_to_add, 0)?; + + let installed_mods = instance.mods(); + + assert_eq!(installed_mods.len(), 1, "No mod was added"); + + let the_mod = installed_mods.first().expect("Asserted before"); + + assert_eq!(the_mod.mod_id(), "add_test_root"); + assert_eq!(the_mod.priority(), 0); + + let expected_files: HashSet<_> = [Link::new("skse.exe", "skse.exe")].into_iter().collect(); + + assert_eq!( + *the_mod.files(), + expected_files, + "Installed files missmatch" + ); + + Ok(()) +} + +#[test] +fn add_filter() -> Result<(), Box> { + let root_config = load_root(); + let mut instance = root_config.load_instance_by_id("instance_minimal")?; + let mod_to_install = root_config + .mod_by_id("add_test_filter") + .expect("Mod not found"); + let files_to_add = files_to_install_mod(&root_config, &instance, &mod_to_install)?; + + insert_mod_to_instance(&mut instance, &mod_to_install, &files_to_add, 0)?; + + let installed_mods = instance.mods(); + + assert_eq!(installed_mods.len(), 1, "No mod was added"); + + let the_mod = installed_mods.first().expect("Asserted before"); + + assert_eq!(the_mod.mod_id(), "add_test_filter"); + assert_eq!(the_mod.priority(), 0); + + let expected_files: HashSet<_> = [Link::new("plugin.esp", "plugin.esp")] + .into_iter() + .collect(); + + assert_eq!( + *the_mod.files(), + expected_files, + "Installed files missmatch" + ); + + Ok(()) +} diff --git a/tests/data/mods/add_test_1/plugin.esp b/tests/data/mods/add_test_1/plugin.esp deleted file mode 100644 index f11894c..0000000 --- a/tests/data/mods/add_test_1/plugin.esp +++ /dev/null @@ -1 +0,0 @@ -plugin.esl-add_test_1 diff --git a/tests/data/mods/add_test_filter/image.jpg b/tests/data/mods/add_test_filter/image.jpg new file mode 100644 index 0000000..9c6e766 --- /dev/null +++ b/tests/data/mods/add_test_filter/image.jpg @@ -0,0 +1 @@ +image.jpg diff --git a/tests/data/mods/add_test_filter/plugin.esp b/tests/data/mods/add_test_filter/plugin.esp new file mode 100644 index 0000000..ed28682 --- /dev/null +++ b/tests/data/mods/add_test_filter/plugin.esp @@ -0,0 +1 @@ +plugin.esp diff --git a/tests/data/mods/add_test_filter/readme.txt b/tests/data/mods/add_test_filter/readme.txt new file mode 100644 index 0000000..b2b2a78 --- /dev/null +++ b/tests/data/mods/add_test_filter/readme.txt @@ -0,0 +1 @@ +readme.txt diff --git a/tests/data/mods/add_test_filter/sub/extra.esp b/tests/data/mods/add_test_filter/sub/extra.esp new file mode 100644 index 0000000..2a19889 --- /dev/null +++ b/tests/data/mods/add_test_filter/sub/extra.esp @@ -0,0 +1 @@ +extra.esp diff --git a/tests/data/mods/add_test_nested/Data/plugin.esp b/tests/data/mods/add_test_nested/Data/plugin.esp new file mode 100644 index 0000000..6cd0f4c --- /dev/null +++ b/tests/data/mods/add_test_nested/Data/plugin.esp @@ -0,0 +1 @@ +plugin.esp-add_test_2 diff --git a/tests/data/mods/add_test_plain/plugin.esp b/tests/data/mods/add_test_plain/plugin.esp new file mode 100644 index 0000000..3762a98 --- /dev/null +++ b/tests/data/mods/add_test_plain/plugin.esp @@ -0,0 +1 @@ +plugin.esp-add_test_1 diff --git a/tests/data/mods/add_test_root/skse.exe b/tests/data/mods/add_test_root/skse.exe new file mode 100644 index 0000000..182bf20 --- /dev/null +++ b/tests/data/mods/add_test_root/skse.exe @@ -0,0 +1 @@ +skse.exe diff --git a/tests/data/root_config_complex.toml b/tests/data/root_config_complex.toml index 63b9589..3dc2818 100644 --- a/tests/data/root_config_complex.toml +++ b/tests/data/root_config_complex.toml @@ -29,5 +29,17 @@ path = "mod2" [mods.mod3] path = "mod3" -[mods.add_test_1] -path = "add_test_1" +[mods.add_test_plain] +path = "add_test_plain" + +[mods.add_test_nested] +path = "add_test_nested" + +[mods.add_test_root] +path = "add_test_root" +root_mod = true + +[mods.add_test_filter] +path = "add_test_filter" +ignore = [ "*.txt", "image.jpg", "sub/*" ] +root_mod = true