Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Futsch1 committed Feb 6, 2022
1 parent 1b25c0c commit a47142d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/item_sort_list/item_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ mod tests {
let mut items: Vec<file_item::FileItem> = vec![];
for _ in 0..6 {
items.push(file_item::FileItem::new(
PathBuf::from(""),
PathBuf::from("test.jpg"),
Box::new(MockResolver::new(call_count.clone())),
true,
"",
Expand Down Expand Up @@ -264,7 +264,7 @@ mod tests {
for hash in hashes {
let encoded = base64::encode(hash);
items.push(file_item::FileItem::new(
PathBuf::from(""),
PathBuf::from("test.jpg"),
Box::new(MockResolver::new(call_count.clone())),
true,
&encoded,
Expand Down Expand Up @@ -301,7 +301,7 @@ mod tests {
item_list.finish_synchronizing(Path::new("tests"));
assert_eq!("tests", item_list.path.to_str().unwrap());

item_list.add_item(Path::new("tests/not_there"), true, "");
item_list.add_item(Path::new("tests/not_there.jpg"), true, "");
assert_eq!(5, item_list.items.len());
item_list.drain_missing();
assert_eq!(4, item_list.items.len());
Expand Down
28 changes: 17 additions & 11 deletions src/item_sort_list/sieve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ mod test {
get_sub_path(
&item_list,
&FileItem::dummy(
"",
"test.jpg",
NaiveDateTime::parse_from_str(input, "%Y-%m-%d %H:%M")
.unwrap()
.timestamp(),
Expand All @@ -330,8 +330,8 @@ mod test {
fn test_sieve_methods() {
let item_list = ItemList {
items: vec![
FileItem::dummy("test/test1", 0, true),
FileItem::dummy("test/test2", 0, false),
FileItem::dummy("test/test1.jpg", 0, true),
FileItem::dummy("test/test2.jpg", 0, false),
],
events: vec![],
path: PathBuf::from(""),
Expand All @@ -350,7 +350,10 @@ mod test {
assert_eq!(sieve_io.creates.borrow().len(), 0);
assert_eq!(sieve_io.renames.borrow().len(), 0);
assert_eq!(sieve_io.removes.borrow().len(), 1);
assert_eq!(sieve_io.removes.borrow()[0].to_str().unwrap(), "test/test2");
assert_eq!(
sieve_io.removes.borrow()[0].to_str().unwrap(),
"test/test2.jpg"
);

sieve_io.reset();
sieve(
Expand All @@ -364,11 +367,11 @@ mod test {
assert_eq!(sieve_io.copies.borrow().len(), 1);
assert_eq!(
sieve_io.copies.borrow()[0].0.to_str().unwrap(),
"test/test1"
"test/test1.jpg"
);
assert_eq!(
sieve_io.copies.borrow()[0].1.to_str().unwrap(),
"target/1970-01/test1"
"target/1970-01/test1.jpg"
);
assert_eq!(sieve_io.creates.borrow().len(), 1);
assert_eq!(
Expand Down Expand Up @@ -396,11 +399,11 @@ mod test {
assert_eq!(sieve_io.renames.borrow().len(), 1);
assert_eq!(
sieve_io.renames.borrow()[0].0.to_str().unwrap(),
"test/test1"
"test/test1.jpg"
);
assert_eq!(
sieve_io.renames.borrow()[0].1.to_str().unwrap(),
"target/1970-01/test1"
"target/1970-01/test1.jpg"
);
assert_eq!(sieve_io.removes.borrow().len(), 0);

Expand All @@ -422,13 +425,16 @@ mod test {
assert_eq!(sieve_io.renames.borrow().len(), 1);
assert_eq!(
sieve_io.renames.borrow()[0].0.to_str().unwrap(),
"test/test1"
"test/test1.jpg"
);
assert_eq!(
sieve_io.renames.borrow()[0].1.to_str().unwrap(),
"target/1970-01/test1"
"target/1970-01/test1.jpg"
);
assert_eq!(sieve_io.removes.borrow().len(), 1);
assert_eq!(sieve_io.removes.borrow()[0].to_str().unwrap(), "test/test2");
assert_eq!(
sieve_io.removes.borrow()[0].to_str().unwrap(),
"test/test2.jpg"
);
}
}

0 comments on commit a47142d

Please sign in to comment.