File: 0003-Fix-compatiblity-with-net-ssh-4.0.patch

package info (click to toggle)
ruby-net-scp 1.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 336 kB
  • ctags: 376
  • sloc: ruby: 2,001; makefile: 2
file content (118 lines) | stat: -rw-r--r-- 4,506 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
From: =?utf-8?q?V=C3=ADt_Ondruch?= <vondruch@redhat.com>
Date: Mon, 27 Feb 2017 13:38:00 +0100
Subject: Fix compatiblity with net-ssh 4.0+

---
 test/test_download.rb | 36 +++++++++++++++++++++++-------------
 test/test_upload.rb   | 10 +++++++---
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/test/test_download.rb b/test/test_download.rb
index 1f2952a..6298070 100644
--- a/test/test_download.rb
+++ b/test/test_download.rb
@@ -70,12 +70,12 @@ class TestDownload < Net::SCP::TestCase
     end
 
     error = nil
-    assert_scripted do
-      begin
-        scp.download!("/path/to/remote.txt")
-      rescue
-        error = $!
-      end
+    Net::SSH::Test::Extensions::IO.with_test_extension do
+    begin
+      scp.download!("/path/to/remote.txt")
+    rescue
+      error = $!
+    end
     end
     assert_equal Net::SCP::Error, error.class
     assert_equal "SCP did not finish successfully (1): File not found: /path/to/remote.txt\n", error.message
@@ -116,7 +116,9 @@ class TestDownload < Net::SCP::TestCase
 
   def test_download_io_with_recursive_should_raise_error
     expect_scp_session "-f -r /path/to/remote.txt"
-    assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", StringIO.new, :recursive => true) }
+    Net::SSH::Test::Extensions::IO.with_test_extension do
+      assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", StringIO.new, :recursive => true) }
+    end
   end
 
   def test_download_io_with_preserve_should_ignore_preserve
@@ -155,7 +157,9 @@ class TestDownload < Net::SCP::TestCase
       channel.gets_data "D0755 0 remote\n"
     end
 
-    assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote") }
+    Net::SSH::Test::Extensions::IO.with_test_extension do
+      assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote") }
+    end
   end
 
   def test_download_should_raise_error_if_gets_not_ok
@@ -168,8 +172,10 @@ class TestDownload < Net::SCP::TestCase
       channel.gets_data "\1"
     end
 
-    e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", "/path/to/local.txt") }
-    assert_equal("\1", e.message)
+    Net::SSH::Test::Extensions::IO.with_test_extension do
+      e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", "/path/to/local.txt") }
+      assert_equal("\1", e.message)
+    end
   end
 
   def test_download_directory_should_raise_error_if_local_exists_and_is_not_directory
@@ -185,8 +191,10 @@ class TestDownload < Net::SCP::TestCase
       channel.sends_ok
     end
 
-    e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote", "/path/to/local", :recursive => true) }
-    assert_match(/exists and is not a directory/, e.message)
+    Net::SSH::Test::Extensions::IO.with_test_extension do
+      e = assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote", "/path/to/local", :recursive => true) }
+      assert_match(/exists and is not a directory/, e.message)
+    end
   end
 
   def test_download_directory_should_create_directory_and_files_locally
@@ -211,7 +219,9 @@ class TestDownload < Net::SCP::TestCase
       channel.sends_ok
     end
 
-    scp.download!("/path/to/remote", "/path/to/local", :recursive => true, :ssh => { :verbose => :debug })
+    Net::SSH::Test::Extensions::IO.with_test_extension do
+      scp.download!("/path/to/remote", "/path/to/local", :recursive => true, :ssh => { :verbose => :debug })
+    end
     assert_equal "a" * 1234, file.io.string
   end
 
diff --git a/test/test_upload.rb b/test/test_upload.rb
index 02b4062..d0f63e2 100644
--- a/test/test_upload.rb
+++ b/test/test_upload.rb
@@ -156,7 +156,9 @@ class TestUpload < Net::SCP::TestCase
       channel.gets_ok
     end
 
-    assert_raises(Net::SCP::Error) { scp.upload!("/path/to/local", "/path/to/remote") }
+    Net::SSH::Test::Extensions::IO.with_test_extension do
+      assert_raises(Net::SCP::Error) { scp.upload!("/path/to/local", "/path/to/remote") }
+    end
   end
 
   def test_upload_empty_directory_should_create_directory_and_finish
@@ -274,7 +276,9 @@ class TestUpload < Net::SCP::TestCase
       channel.gets_data "\1"
     end
 
-    e = assert_raises(Net::SCP::Error) { scp.upload!("/path/to/local.txt", "/path/to/remote.txt") }
-    assert_equal("\1", e.message)
+    Net::SSH::Test::Extensions::IO.with_test_extension do
+      e = assert_raises(Net::SCP::Error) { scp.upload!("/path/to/local.txt", "/path/to/remote.txt") }
+      assert_equal("\1", e.message)
+    end
   end
 end