Skip to content

Commit

Permalink
apply suggest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leonzchang committed Nov 29, 2023
1 parent b0a001c commit 40c034e
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/cmd/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,6 @@ mod tests {
use ignore::gitignore::GitignoreBuilder;
use std::env;

fn path_to_buf(root: &str, file_name: &str) -> PathBuf {
let mut path = PathBuf::from(root);
path.push(file_name);
path
}

#[test]
fn test_filter_ignored_files() {
let current_dir = env::current_dir().unwrap();
Expand All @@ -209,8 +203,8 @@ mod tests {
.unwrap()
.build()
.unwrap();
let should_remain = path_to_buf(current_dir.to_str().unwrap(), "record.text");
let should_filter = path_to_buf(current_dir.to_str().unwrap(), "index.html");
let should_remain = current_dir.join("record.text");
let should_filter = current_dir.join("index.html");

let remain = filter_ignored_files(ignore, &[should_remain.clone(), should_filter]);
assert_eq!(remain, vec![should_remain])
Expand All @@ -226,9 +220,9 @@ mod tests {
.build()
.unwrap();

let parent_dir = format!("{}/../", current_dir.to_str().unwrap());
let should_remain = path_to_buf(&parent_dir, "record.text");
let should_filter = path_to_buf(&parent_dir, "index.html");
let parent_dir = current_dir.join("..");
let should_remain = parent_dir.join("record.text");
let should_filter = parent_dir.join("index.html");

let remain = filter_ignored_files(ignore, &[should_remain.clone(), should_filter]);
assert_eq!(remain, vec![should_remain])
Expand Down

0 comments on commit 40c034e

Please sign in to comment.