Fix tests from tree view fallout

This commit is contained in:
Ben S 2015-02-04 01:12:08 +00:00
parent d5aa3208b6
commit 1bced1423b
2 changed files with 17 additions and 14 deletions

View File

@ -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 });

View File

@ -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())
}