~zethra/poki-launcher

f520b9b1775333297edf6754ed622cbc873d0b14 — Sashanoraa 6 months ago e68e0ad
Use temp dir for files in tests

Signed-off-by: Sashanoraa <sasha@sashanoraa.gay>
2 files changed, 18 insertions(+), 14 deletions(-)

M Cargo.lock
M lib-poki-launcher/src/desktop_entry.rs
M Cargo.lock => Cargo.lock +2 -0
@@ 1,5 1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "aho-corasick"
version = "0.7.15"

M lib-poki-launcher/src/desktop_entry.rs => lib-poki-launcher/src/desktop_entry.rs +16 -14
@@ 340,16 340,16 @@ mod test {
    }

    mod parse_desktop_file {
        use crate::App;
        use std::env::temp_dir;
        use std::fs::{remove_file, File};
        use std::io::prelude::*;

        use super::*;

        #[test]
        fn vaild_file_exist() {
            use crate::App;
            use std::fs::{remove_file, File};
            use std::io::prelude::*;
            use std::path::Path;

            let path = Path::new("./test.desktop");
            let path = temp_dir().join("./test.desktop");
            let mut file = File::create(&path).unwrap();
            file.write_all(
                b"[Desktop Entry]


@@ 362,7 362,7 @@ mod test {
            let other_app = App::new(
                "Test".to_owned(),
                "testicon".to_owned(),
                vec!["/usr/bin/test".to_owned(), "--with-flag".to_owned()],
                ovec(&["/usr/bin/test", "--with-flag"]),
                false,
            );
            // Note, apps will have different uuids but Eq doesn't consider them


@@ 372,12 372,7 @@ mod test {

        #[test]
        fn file_with_args() {
            use crate::App;
            use std::fs::{remove_file, File};
            use std::io::prelude::*;
            use std::path::Path;

            let path = Path::new("./test2.desktop");
            let path = temp_dir().join("./test2.desktop");
            let mut file = File::create(&path).unwrap();
            file.write_all(
                b"[Desktop Entry]


@@ 390,7 385,14 @@ mod test {
            let other_app = App::new(
                "Test".to_owned(),
                "testicon".to_owned(),
                ovec(&["/usr/bin/test", "--with-flag", "Test", "--icon", "testicon", "./test2.desktop"]),
                ovec(&[
                    "/usr/bin/test",
                    "--with-flag",
                    "Test",
                    "--icon",
                    "testicon",
                    path.to_string_lossy().as_ref(),
                ]),
                false,
            );
            // Note, apps will have different uuids but Eq doesn't consider them