Skip to content

Commit 15d443a

Browse files
committed
refactor(database): simplify test setup with temp_mock_db
1 parent e587e24 commit 15d443a

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

src/advisory/database.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,7 @@ mod tests {
362362

363363
#[test]
364364
fn open_fixture_advisory_dir() {
365-
let fixture_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures");
366-
// Create a mini advisory-db structure
367-
let db_dir = fixture_dir.join("mock_db");
368-
let gem_dir = db_dir.join("gems").join("test");
369-
std::fs::create_dir_all(&gem_dir).unwrap();
370-
std::fs::copy(
371-
fixture_dir.join("advisory/CVE-2020-1234.yml"),
372-
gem_dir.join("CVE-2020-1234.yml"),
373-
)
374-
.unwrap();
365+
let (db_dir, _) = temp_mock_db("fixture");
375366

376367
let db = Database::open(&db_dir).unwrap();
377368
assert!(!db.is_git());
@@ -388,7 +379,6 @@ mod tests {
388379
let (vulns, _errors) = db.check_gem("test", &Version::parse("1.0.0").unwrap());
389380
assert!(vulns.is_empty());
390381

391-
// Cleanup
392382
std::fs::remove_dir_all(&db_dir).unwrap();
393383
}
394384

0 commit comments

Comments
 (0)