Skip to content

Commit

Permalink
Cleanup Fs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dotdat committed Oct 1, 2024
1 parent 589df2b commit f7adf2b
Showing 1 changed file with 2 additions and 56 deletions.
58 changes: 2 additions & 56 deletions crates/rover-std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,54 +503,6 @@ mod tests {
}
}

//#[tokio::test]
//async fn test_watch_file() -> Result<()> {
// // create a temporary file that we'll make changes to for events to be watched
// let mut file = NamedTempFile::new()?;
// let path = Utf8PathBuf::from_path_buf(file.path().to_path_buf())
// .unwrap_or_else(|path| panic!("Unable to create Utf8PathBuf from path: {:?}", path));

// let (tx, rx) = unbounded_channel();
// let rx = Arc::new(Mutex::new(rx));
// let cancellation_token = Fs::watch_file(path.clone(), tx);
// sleep(Duration::from_millis(1500)).await;
// {
// let rx = rx.lock().await;
// assert_that!(rx.is_empty()).is_true();
// }
// file.write_all(b"some update")?;
// file.flush()?;
// let result = tokio::time::timeout(Duration::from_millis(2000), {
// let rx = rx.clone();
// async move {
// let mut output = None;
// let mut rx = rx.lock().await;
// if let Some(message) = rx.recv().await {
// output = Some(message);
// }
// output
// }
// })
// .await;
// assert_that!(result)
// .is_ok()
// .is_some()
// .is_ok()
// .is_equal_to(());
// {
// let rx = rx.lock().await;
// assert_that!(rx.is_closed()).is_false();
// }
// cancellation_token.cancel();
// // Kick the event loop so that the cancellation future gets called
// sleep(Duration::from_millis(0)).await;
// {
// let rx = rx.lock().await;
// assert_that!(rx.is_closed()).is_true();
// }
// Ok(())
//}

#[tokio::test]
async fn test_watch_file() -> Result<()> {
// create a temporary file that we'll make changes to for events to be watched
Expand All @@ -576,15 +528,9 @@ mod tests {
file.write_all(b"some update")?;
file.flush()?;

let mut writeable_file = OpenOptions::new()
.write(true)
.truncate(true)
.open(path)
.expect("Cannot open file");
let mut writeable_file = OpenOptions::new().write(true).truncate(true).open(path)?;

writeable_file
.write("some change".as_bytes())
.expect("couldn't write to file");
writeable_file.write_all("some change".as_bytes())?;

let result = tokio::time::timeout(Duration::from_millis(2000), {
let rx = rx.clone();
Expand Down

0 comments on commit f7adf2b

Please sign in to comment.