summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Olsen <brian@maven-group.org>2017-05-23 22:31:43 +0200
committerBrian Olsen <brian@maven-group.org>2017-05-23 22:31:43 +0200
commit5e9c8905b1cba55351bd6f4c7ac74725ea7df12f (patch)
tree917d8b8b7c68f5a4d4ad629a8a16e0e571349de3 /tests
parent0b5d368292bbd4682c767fa6b5b0753d260ae43f (diff)
downloadssh2-rs-5e9c8905b1cba55351bd6f4c7ac74725ea7df12f.zip
Fix exit_status example
In the example in the documentation that calls exit_status and in the smoke integration test exit_status is called before the channel is closed and it will therefore always return Ok(0). I have fixed this by calling wait_close() first and by adding a bad_smoke test that calls false and checks that the exit_status is 1.
Diffstat (limited to 'tests')
-rw-r--r--tests/channel.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/channel.rs b/tests/channel.rs
index e4e0f16..2ade997 100644
--- a/tests/channel.rs
+++ b/tests/channel.rs
@@ -10,9 +10,23 @@ fn smoke() {
channel.exec("true").unwrap();
channel.wait_eof().unwrap();
assert!(channel.eof());
+ channel.close().unwrap();
+ channel.wait_close().unwrap();
assert_eq!(channel.exit_status().unwrap(), 0);
+ assert!(channel.eof());
+}
+
+#[test]
+fn bad_smoke() {
+ let (_tcp, sess) = ::authed_session();
+ let mut channel = sess.channel_session().unwrap();
+ channel.flush().unwrap();
+ channel.exec("false").unwrap();
+ channel.wait_eof().unwrap();
+ assert!(channel.eof());
channel.close().unwrap();
channel.wait_close().unwrap();
+ assert_eq!(channel.exit_status().unwrap(), 1);
assert!(channel.eof());
}