MysteryBlokHed / databind

Expand the functionality of Minecraft Datapacks.
https://databind.rtfd.io/en/stable
GNU General Public License v3.0
4 stars 0 forks source link

Refactor tests to improve reusability #98

Closed MysteryBlokHed closed 3 years ago

MysteryBlokHed commented 3 years ago

Every test starts with very similar code that looks something like this:

let mut path = tests::resources();
path.push("some_test_directory");

let out = TempDir::new("some_test_directory").expect("Could not create tempdir for test");

tests::run_with_args(
    "cargo",
    &[
        "run",
        "--",
        path.to_str().unwrap(),
        "--ignore-config",
        "--out",
        out.path().to_str().unwrap(),
    ],
    None,
);

Since this code is used in basically every test, it would be a good idea to move the code to a function that returns out and, if it's used (I can't remember if any tests use it or not), path.