@@ -129,7 +129,7 @@ defmodule SSHKit.ConnectionTest do
129129 end )
130130
131131 conn = % Connection {
132- host: 'foo .io' ,
132+ host: 'test .io' ,
133133 port: 22 ,
134134 options: [ user_interaction: false ] ,
135135 ref: :connection_ref
@@ -140,7 +140,7 @@ defmodule SSHKit.ConnectionTest do
140140 end
141141
142142 describe "reopen/2" do
143- test "opens a new connection with the same options as the existing connection" do
143+ test "opens a new connection with the same options as an existing connection" do
144144 conn = % Connection {
145145 host: 'test.io' ,
146146 port: 22 ,
@@ -160,7 +160,7 @@ defmodule SSHKit.ConnectionTest do
160160 assert reopen ( conn ) == { :ok , new_conn }
161161 end
162162
163- test "reopens a connection on new port" do
163+ test "reopens a connection on a new port" do
164164 conn = % Connection {
165165 host: 'test.io' ,
166166 port: 22 ,
@@ -178,12 +178,12 @@ defmodule SSHKit.ConnectionTest do
178178 assert reopen ( conn , port: 666 ) == { :ok , new_conn }
179179 end
180180
181- test "errors when unable to open connection" do
181+ test "errors when unable to open a connection" do
182182 conn = % Connection {
183183 host: 'test.io' ,
184184 port: 22 ,
185- options: [ user_interaction: false ] ,
186- ref: :sandbox
185+ options: [ ] ,
186+ ref: :connection_ref
187187 }
188188
189189 expect ( @ core , :connect , fn _ , _ , _ , _ ->
@@ -193,4 +193,30 @@ defmodule SSHKit.ConnectionTest do
193193 assert reopen ( conn ) == { :error , :failed }
194194 end
195195 end
196+
197+ describe "info/1" do
198+ test "returns information about a connection" do
199+ if function_exported? ( @ core , :connection_info , 1 ) do
200+ expect ( @ core , :connection_info , fn ref ->
201+ assert ref == :connection_ref
202+ [ info: :test ]
203+ end )
204+ else
205+ expect ( @ core , :connection_info , fn ref , keys ->
206+ assert ref == :connection_ref
207+ assert keys == [ :client_version , :server_version , :user , :peer , :sockname ]
208+ [ info: :test ]
209+ end )
210+ end
211+
212+ conn = % Connection {
213+ host: 'test.io' ,
214+ port: 22 ,
215+ options: [ ] ,
216+ ref: :connection_ref
217+ }
218+
219+ assert info ( conn ) == [ info: :test ]
220+ end
221+ end
196222end
0 commit comments