From 1bced1423bf46acb2d7842e07d95c6b695f44cb3 Mon Sep 17 00:00:00 2001 From: Ben S Date: Wed, 4 Feb 2015 01:12:08 +0000 Subject: [PATCH] Fix tests from tree view fallout --- src/file.rs | 20 ++++++++++++-------- src/filetype.rs | 11 +++++------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/file.rs b/src/file.rs index 6d259c0..c841719 100644 --- a/src/file.rs +++ b/src/file.rs @@ -432,6 +432,10 @@ pub mod test { assert_eq!(None, super::ext("jarlsberg")) } + pub fn new_file(stat: io::FileStat, path: &'static str) -> File { + File::with_stat(stat, &Path::new(path), None, false) + } + pub fn dummy_stat() -> io::FileStat { io::FileStat { size: 0, @@ -463,7 +467,7 @@ pub mod test { let mut stat = dummy_stat(); stat.unstable.uid = 1000; - let file = File::with_stat(stat, &Path::new("/hi"), None); + let file = new_file(stat, "/hi"); let mut users = MockUsers::with_current_uid(1000); users.add_user(User { uid: 1000, name: "enoch".to_string(), primary_group: 100 }); @@ -477,7 +481,7 @@ pub mod test { let mut stat = dummy_stat(); stat.unstable.uid = 1000; - let file = File::with_stat(stat, &Path::new("/hi"), None); + let file = new_file(stat, "/hi"); let mut users = MockUsers::with_current_uid(1000); @@ -490,7 +494,7 @@ pub mod test { let mut stat = dummy_stat(); stat.unstable.uid = 1000; - let file = File::with_stat(stat, &Path::new("/hi"), None); + let file = new_file(stat, "/hi"); let mut users = MockUsers::with_current_uid(3); users.add_user(User { uid: 1000, name: "enoch".to_string(), primary_group: 100 }); @@ -504,7 +508,7 @@ pub mod test { let mut stat = dummy_stat(); stat.unstable.uid = 1000; - let file = File::with_stat(stat, &Path::new("/hi"), None); + let file = new_file(stat, "/hi"); let mut users = MockUsers::with_current_uid(3); @@ -521,7 +525,7 @@ pub mod test { let mut stat = dummy_stat(); stat.unstable.gid = 100; - let file = File::with_stat(stat, &Path::new("/hi"), None); + let file = new_file(stat, "/hi"); let mut users = MockUsers::with_current_uid(3); users.add_group(Group { gid: 100, name: "folk".to_string(), members: vec![] }); @@ -535,7 +539,7 @@ pub mod test { let mut stat = dummy_stat(); stat.unstable.gid = 100; - let file = File::with_stat(stat, &Path::new("/hi"), None); + let file = new_file(stat, "/hi"); let mut users = MockUsers::with_current_uid(3); @@ -548,7 +552,7 @@ pub mod test { let mut stat = dummy_stat(); stat.unstable.gid = 100; - let file = File::with_stat(stat, &Path::new("/hi"), None); + let file = new_file(stat, "/hi"); let mut users = MockUsers::with_current_uid(3); users.add_user(User { uid: 3, name: "eve".to_string(), primary_group: 100 }); @@ -563,7 +567,7 @@ pub mod test { let mut stat = dummy_stat(); stat.unstable.gid = 100; - let file = File::with_stat(stat, &Path::new("/hi"), None); + let file = new_file(stat, "/hi"); let mut users = MockUsers::with_current_uid(3); users.add_user(User { uid: 3, name: "eve".to_string(), primary_group: 12 }); diff --git a/src/filetype.rs b/src/filetype.rs index ffb374f..1259337 100644 --- a/src/filetype.rs +++ b/src/filetype.rs @@ -149,30 +149,29 @@ impl<'a> HasType for File<'a> { #[cfg(test)] mod test { use super::*; - use file::File; - use file::test::dummy_stat; + use file::test::{dummy_stat, new_file}; #[test] fn lowercase() { - let file = File::with_stat(dummy_stat(), &Path::new("/barracks.wav"), None); + let file = new_file(dummy_stat(), "/barracks.wav"); assert_eq!(FileType::Lossless, file.get_type()) } #[test] fn uppercase() { - let file = File::with_stat(dummy_stat(), &Path::new("/BARRACKS.WAV"), None); + let file = new_file(dummy_stat(), "/BARRACKS.WAV"); assert_eq!(FileType::Lossless, file.get_type()) } #[test] fn cargo() { - let file = File::with_stat(dummy_stat(), &Path::new("/Cargo.toml"), None); + let file = new_file(dummy_stat(), "/Cargo.toml"); assert_eq!(FileType::Immediate, file.get_type()) } #[test] fn not_cargo() { - let file = File::with_stat(dummy_stat(), &Path::new("/cargo.toml"), None); + let file = new_file(dummy_stat(), "/cargo.toml"); assert_eq!(FileType::Normal, file.get_type()) }