use std::error::Error;

use pgrep;

pub mod config;

#[test]
fn search_string_file() -> Result<(), Box<dyn Error>> {
    let config = config::Config::new(
        "hello".to_string(),
        "search_string_file.txt".to_string(),
        "hello world".to_string(),
    );
    let config = config.setup()?;

    let cli =
        pgrep::cli::Cli::new(&vec!["pgrep".to_string(), config.query, config.filename])?;

    let result = cli.run()?;

    match result {
        0 => Ok(()),
        _ => Err("search_string_file failed".into()),
    }
}