Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Fs tests #2182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading