Skip to content

Commit

Permalink
Sort paths to assert on
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Sichert <[email protected]>
  • Loading branch information
pablosichert committed Jan 10, 2021
1 parent 7001445 commit 3954aed
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/file-source/tests/glob.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use file_source::paths_provider::{glob::Glob, PathsProvider};
use std::collections::HashSet;

fn sorted<T: Ord>(mut input: Vec<T>) -> Vec<T> {
input.sort();
input
}

#[test]
fn test_glob_include_plain() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -10,11 +14,11 @@ fn test_glob_include_plain() -> Result<(), Box<dyn std::error::Error>> {
let paths = glob.paths()?;

assert_eq!(
paths.into_iter().collect::<HashSet<_>>(),
paths,
["./tests/files/foo.log"]
.iter()
.map(std::path::PathBuf::from)
.collect::<HashSet<_>>()
.collect::<Vec<_>>()
);

Ok(())
Expand All @@ -29,11 +33,11 @@ fn test_glob_include_curly_braces() -> Result<(), Box<dyn std::error::Error>> {
let paths = glob.paths()?;

assert_eq!(
paths.into_iter().collect::<HashSet<_>>(),
sorted(paths),
["./tests/files/foo.log", "./tests/files/bar.log"]
.iter()
.map(std::path::PathBuf::from)
.collect::<HashSet<_>>()
.collect::<Vec<_>>()
);

Ok(())
Expand All @@ -48,11 +52,11 @@ fn test_glob_include_curly_braces_exclude_star() -> Result<(), Box<dyn std::erro
let paths = glob.paths()?;

assert_eq!(
paths.into_iter().collect::<HashSet<_>>(),
paths,
["./tests/files/bar.log"]
.iter()
.map(std::path::PathBuf::from)
.collect::<HashSet<_>>()
.collect::<Vec<_>>()
);

Ok(())
Expand Down

0 comments on commit 3954aed

Please sign in to comment.