-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test to include more packages
- Loading branch information
Showing
13 changed files
with
72 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.siq filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,52 @@ | ||
use opensi_core::prelude::*; | ||
|
||
const PATH: &str = "tests/data/slamjam2.siq"; | ||
use std::fs; | ||
use std::path::PathBuf; | ||
|
||
#[test] | ||
fn open_pack() { | ||
let package = Package::open_zip_file(PATH); | ||
assert_eq!(package.is_ok(), true); | ||
} | ||
const PACKS_DIR: &str = "tests/data"; | ||
|
||
#[test] | ||
fn read_package_name() { | ||
let package = Package::open_zip_file(PATH).expect("pack is not found"); | ||
assert_eq!(package.name, "SLAM JAM 2".to_owned()); | ||
fn open_packs() { | ||
for pack in get_packs() { | ||
let package = Package::open_zip_file(&pack); | ||
let package_name = pack.file_name().unwrap().to_str().unwrap(); | ||
|
||
assert!(package.is_ok(), "Can't open package {}, error is {}", package_name, package.err().unwrap()); | ||
} | ||
} | ||
|
||
#[test] | ||
fn resave_test() { | ||
let package_original = Package::open_zip_file(PATH).expect("Pack is not found"); | ||
let bytes = &package_original.to_bytes().expect("Can't serialize package to bytes"); | ||
let package_resaved = Package::from_zip_buffer(bytes).expect("Can't read package from buffer"); | ||
for pack in get_packs() { | ||
let package_original = Package::open_zip_file(&pack).expect("Pack is not found"); | ||
let bytes = &package_original.to_bytes().expect("Can't serialize package to bytes"); | ||
let package_resaved = | ||
Package::from_zip_buffer(bytes).expect("Can't read package from buffer"); | ||
|
||
let package_name = pack.file_name().unwrap().to_str().unwrap(); | ||
|
||
assert_eq!( | ||
package_original, | ||
package_resaved, | ||
"Package {} resaving produced different results", | ||
package_name | ||
); | ||
} | ||
} | ||
|
||
fn get_packs() -> Vec<PathBuf> { | ||
let mut packs = Vec::new(); | ||
|
||
if let Ok(entries) = fs::read_dir(PACKS_DIR) { | ||
for entry in entries { | ||
if let Ok(entry) = entry { | ||
let path = entry.path(); | ||
if path.is_file() && path.extension().unwrap_or_default() == "siq" { | ||
packs.push(path); | ||
} | ||
} | ||
} | ||
} | ||
|
||
assert_eq!(package_original, package_resaved); | ||
packs | ||
} |
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
crates/opensi-core/tests/data/Obschie_Voprosy_Ot_Slavyan_Ch_1.siq
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Binary file not shown.
Git LFS file not shown