Skip to content

Commit 7eb68c8

Browse files
committed
Improve test_sftp_subsystem: Test write/read-ing file
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
1 parent 47b05ee commit 7eb68c8

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/openssh.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,8 @@ async fn local_socket_forward() {
828828
async fn test_sftp_subsystem() {
829829
use openssh_sftp_client::highlevel::Sftp;
830830

831+
let content = b"Helop, world!\n";
832+
831833
for session in connects().await {
832834
let mut child = session
833835
.subsystem("sftp")
@@ -837,15 +839,23 @@ async fn test_sftp_subsystem() {
837839
.await
838840
.unwrap();
839841

840-
Sftp::new(
842+
let sftp = Sftp::new(
841843
child.stdin().take().unwrap(),
842844
child.stdout().take().unwrap(),
843845
Default::default(),
844846
)
845847
.await
846-
.unwrap()
847-
.close()
848-
.await
849848
.unwrap();
849+
850+
let file_path = "/tmp/file";
851+
852+
{
853+
let mut fs = sftp.fs();
854+
855+
fs.write(file_path, content).await.unwrap();
856+
assert_eq!(&*sftp.fs().read(file_path).await.unwrap(), content);
857+
}
858+
859+
sftp.close().await.unwrap();
850860
}
851861
}

0 commit comments

Comments
 (0)