use super::super::config::*;
use super::super::import_dats;
use super::*;
use std::path::PathBuf;
use tempfile::{NamedTempFile, TempDir};
#[tokio::test]
async fn test() {
let _guard = MUTEX.lock().await;
let test_directory = Path::new("tests");
let progress_bar = ProgressBar::hidden();
let db_file = NamedTempFile::new().unwrap();
let pool = establish_connection(db_file.path().to_str().unwrap()).await;
let mut connection = pool.acquire().await.unwrap();
let rom_directory = TempDir::new_in(test_directory).unwrap();
set_rom_directory(&mut connection, PathBuf::from(rom_directory.path())).await;
let tmp_directory = TempDir::new_in(test_directory).unwrap();
set_tmp_directory(&mut connection, PathBuf::from(tmp_directory.path())).await;
let matches = import_dats::subcommand()
.get_matches_from(["import-dats", "tests/Test System (20240704) (IRD).dat"]);
import_dats::main(&mut connection, &matches, &progress_bar)
.await
.unwrap();
let ird_path = test_directory.join("Test Game (USA).ird");
let game = find_games(&mut connection).await.remove(0);
let (ird_file, header) = parse_ird(&ird_path).await.unwrap();
let parent_roms = find_roms_by_game_id_no_parents(&mut connection, game.id).await;
import_ird(
&mut connection,
&progress_bar,
&game,
&ird_file,
header,
parent_roms.first(),
)
.await
.unwrap();
let roms = find_roms(&mut connection).await;
assert_eq!(roms.len(), 208);
}