Skip to content

Commit

Permalink
remove unnecessary sort and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
allie-wake-up committed Jan 5, 2023
1 parent 28b88bb commit 438f765
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,23 @@ mod tests {
let mut result: Vec<u8> = vec![];
show(
&mut result,
Show::new(Some(String::from("dir"))),
Show::new(Some(String::from("same"))),
get_test_settings(),
)
.unwrap();
assert_eq!(String::from_utf8(result).unwrap().trim(), "dir");
assert_eq!(String::from_utf8(result).unwrap().trim(), "same");
}

#[test]
fn print_password_in_dir() {
let mut result: Vec<u8> = vec![];
show(
&mut result,
Show::new(Some(String::from("dir/test"))),
Show::new(Some(String::from("same/test"))),
get_test_settings(),
)
.unwrap();
assert_eq!(String::from_utf8(result).unwrap().trim(), "dir/test");
assert_eq!(String::from_utf8(result).unwrap().trim(), "same/test");
}

#[test]
Expand All @@ -162,7 +162,7 @@ mod tests {
let result_string = String::from_utf8(result).unwrap();
assert!(result_string.contains("test"));
assert!(result_string.contains("pointguard.dev"));
assert!(result_string.contains("dir"));
assert!(result_string.contains("same"));
assert!(result_string.contains("unique"));
assert!(!result_string.contains("notinstore"));
}
Expand All @@ -172,14 +172,14 @@ mod tests {
let mut result: Vec<u8> = vec![];
show(
&mut result,
Show::new(Some(String::from("dir/"))),
Show::new(Some(String::from("same/"))),
get_test_settings(),
)
.unwrap();
let result_string = String::from_utf8(result).unwrap();
assert!(result_string.contains("test"));
assert!(result_string.contains("unique"));
assert!(result_string.contains("dir"));
assert!(result_string.contains("same"));
assert!(!result_string.contains("notinstore"));
}
}
21 changes: 10 additions & 11 deletions src/show/pgtree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,17 @@ mod tests {

#[test]
fn build_tree_test() {
let mut tree = build_tree(&PathBuf::from("test-store-enc"), None).unwrap();
tree.sort();
let tree = build_tree(&PathBuf::from("test-store-enc"), None).unwrap();
assert_eq!(tree.file_stem, "Point Guard Password Store");
assert_eq!(tree.children.len(), 6);
assert_eq!(tree.children[0].file_stem, "dir");
assert_eq!(tree.children[0].children.len(), 0);
assert_eq!(tree.children[1].file_stem, "dir");
assert_eq!(tree.children[1].children.len(), 2);
assert_eq!(tree.children[1].children[0].file_stem, "test");
assert_eq!(tree.children[1].children[0].children.len(), 0);
assert_eq!(tree.children[2].file_stem, "empty");
assert_eq!(tree.children[3].file_stem, "empty1");
assert_eq!(tree.children[4].file_stem, "pointguard.dev");
assert_eq!(tree.children[0].file_stem, "empty");
assert_eq!(tree.children[1].file_stem, "empty1");
assert_eq!(tree.children[2].file_stem, "pointguard.dev");
assert_eq!(tree.children[3].file_stem, "same");
assert_eq!(tree.children[3].children.len(), 0);
assert_eq!(tree.children[4].file_stem, "same");
assert_eq!(tree.children[4].children.len(), 2);
assert_eq!(tree.children[4].children[0].file_stem, "test");
assert_eq!(tree.children[4].children[0].children.len(), 0);
}
}
1 change: 0 additions & 1 deletion test-store/dir.gpg

This file was deleted.

1 change: 0 additions & 1 deletion test-store/dir/test.gpg

This file was deleted.

4 changes: 4 additions & 0 deletions test-store/empty/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions test-store/empty1/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
1 change: 1 addition & 0 deletions test-store/same.gpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
same
1 change: 1 addition & 0 deletions test-store/same/test.gpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
same/test
File renamed without changes.

0 comments on commit 438f765

Please sign in to comment.