Skip to content

Commit

Permalink
Better test coverage for unftp-sbe-fs::Filesystem::{del,rmd}
Browse files Browse the repository at this point in the history
* Add a functional test for rmd
* Fix the final assertion's path for the del test.
  • Loading branch information
asomers authored and hannesdejager committed Aug 13, 2023
1 parent e726d23 commit 6f9618a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion crates/unftp-sbe-fs/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,25 @@ async fn dele() {

ftp_stream.login("hoi", "jij").await.unwrap();
ftp_stream.rm(file_name).await.unwrap();
assert_eq!(std::fs::metadata(file_name).unwrap_err().kind(), std::io::ErrorKind::NotFound);
assert_eq!(std::fs::metadata(file_in_root.path()).unwrap_err().kind(), std::io::ErrorKind::NotFound);
}

#[tokio::test]
async fn rmd() {
let addr = "127.0.0.1:1243";
let root = std::env::temp_dir();

tokio::spawn(libunftp::Server::with_fs(root.clone()).listen(addr));
tokio::time::sleep(Duration::new(1, 0)).await;
let mut ftp_stream = FtpStream::connect(addr).await.unwrap();
let dir_in_root = tempfile::tempdir_in(root).unwrap();
let file_name = dir_in_root.path().file_name().unwrap().to_str().unwrap();

ensure_login_required(ftp_stream.rm(file_name).await);

ftp_stream.login("hoi", "jij").await.unwrap();
ftp_stream.rmdir(file_name).await.unwrap();
assert_eq!(std::fs::metadata(dir_in_root.path()).unwrap_err().kind(), std::io::ErrorKind::NotFound);
}

#[tokio::test]
Expand Down

0 comments on commit 6f9618a

Please sign in to comment.