#[cfg(test)]
mod tests {
    use meka::utils::{get_path_var, parse_cmd};
    use std::path::PathBuf;

    #[test]
    fn test_parse_cmd_empty_args() {
        let args: &[String] = &[];
        let res = parse_cmd(args, &[PathBuf::from("make")], false);
        assert!(res.is_err());
    }

    #[test]
    fn test_parse_cmd_empty_args_good_path() {
        let path_var = get_path_var();
        let args: &[String] = &[];
        let res = parse_cmd(args, &path_var, false);
        assert!(res.is_err());
        let err = res.unwrap_err();
        assert!(err.contains("not be empty"));
    }

    #[test]
    fn test_parse_cmd_ok() {
        let path_var = get_path_var();
        let res = parse_cmd(&["make".to_string()], &path_var, false);
        assert!(res.is_ok());
        assert_eq!(res.unwrap().args, vec!["make"]);
    }

    #[test]
    fn test_parse_wrap_shell_ok() {
        let path_var = get_path_var();
        let res = parse_cmd(&["make".to_string()], &path_var, true);
        assert!(res.is_ok());
        assert_eq!(res.unwrap().args, vec!["sh", "-c", "make"]);

        let args = vec!["echo 1", "&&", "echo", "2"];
        let res = parse_cmd(&args, &path_var, true);
        assert!(res.is_ok());
        assert_eq!(res.unwrap().args, vec!["sh", "-c", "echo 1 && echo 2"]);
    }
}
