From 6b17409a7246b867c8d1a2ff2b1967c9ec1be13d Mon Sep 17 00:00:00 2001 From: "Ericson \"Fogo\" Soares" Date: Fri, 13 Jan 2023 17:02:57 -0300 Subject: [PATCH] Fixing unit tests for MacOS --- core/src/location/manager/watcher/macos.rs | 1 - core/src/location/manager/watcher/mod.rs | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/location/manager/watcher/macos.rs b/core/src/location/manager/watcher/macos.rs index 31aad1d9f..2459eb67b 100644 --- a/core/src/location/manager/watcher/macos.rs +++ b/core/src/location/manager/watcher/macos.rs @@ -8,7 +8,6 @@ use notify::{ event::{CreateKind, DataChange, ModifyKind, RenameMode}, Event, EventKind, }; -use tokio::{fs, io}; use tracing::trace; use super::{ diff --git a/core/src/location/manager/watcher/mod.rs b/core/src/location/manager/watcher/mod.rs index a42792a9a..8c071978a 100644 --- a/core/src/location/manager/watcher/mod.rs +++ b/core/src/location/manager/watcher/mod.rs @@ -333,7 +333,10 @@ mod tests { Config, Event, EventKind, RecommendedWatcher, Watcher, }; use std::io::ErrorKind; - use std::{path::Path, time::Duration}; + use std::{ + path::{Path, PathBuf}, + time::Duration, + }; use tempfile::{tempdir, TempDir}; use tokio::{fs, io::AsyncWriteExt, sync::mpsc, time::sleep}; use tracing::{debug, error}; @@ -375,8 +378,10 @@ mod tests { Ok(maybe_event) => { let event = maybe_event.expect("Failed to receive event"); debug!("Received event: {event:#?}"); - // Using `ends_with` here due to a weird edge case on CI tests at MacOS - if event.paths[0].ends_with(path) && event.kind == expected_event { + // Using `ends_with` and removing root path here due to a weird edge case on CI tests at MacOS + if event.paths[0].ends_with(path.iter().skip(1).collect::()) + && event.kind == expected_event + { debug!("Received expected event: {expected_event:#?}"); break; }