This repository was archived by the owner on May 18, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ import (
10
10
11
11
// Driver is a driver based on SSH.
12
12
type Driver struct {
13
- host string
14
- sshClient * openssh.Client
15
- rsyncClient * rsync.Client
13
+ Host string
14
+ SSHClient * openssh.Client
15
+ RsyncClient * rsync.Client
16
16
}
17
17
18
18
// NewDriver creates a new SSH driver that communicates with the given host.
@@ -31,15 +31,15 @@ func NewDriver(host string) (*Driver, error) {
31
31
32
32
// RunCommand runs the specified command on the host.
33
33
func (drv Driver ) RunCommand (args []string ) error {
34
- return drv .sshClient .RunCommand (args )
34
+ return drv .SSHClient .RunCommand (args )
35
35
}
36
36
37
37
// Upload copies files to the host.
38
38
func (drv Driver ) Upload (dst string , src ... string ) error {
39
- return drv .rsyncClient .Copy (dst , src ... )
39
+ return drv .RsyncClient .Copy (dst , src ... )
40
40
}
41
41
42
42
// String returns the driver's name.
43
43
func (drv Driver ) String () string {
44
- return fmt .Sprintf ("SSH driver (host: %s)" , drv .sshClient .Host )
44
+ return fmt .Sprintf ("SSH driver (host: %s)" , drv .SSHClient .Host )
45
45
}
Original file line number Diff line number Diff line change @@ -12,10 +12,17 @@ func TestDriverInterface(t *testing.T) {
12
12
assert .Implements (t , (* driver .Driver )(nil ), new (Driver ))
13
13
}
14
14
15
- func TestString (t * testing.T ) {
15
+ func TestNewDriver (t * testing.T ) {
16
16
drv , err := NewDriver ("some-user@some-host:1234" )
17
- assert .NoError (t , err )
18
- assert .Equal (t , "SSH driver (host: some-host)" , drv .String ())
17
+ if assert .NoError (t , err ) {
18
+ assert .Equal (t , "some-host" , drv .SSHClient .Host )
19
+ assert .Equal (t , 1234 , drv .SSHClient .Port )
20
+ assert .Equal (t , "some-user" , drv .SSHClient .User )
21
+ assert .Equal (t , "some-host" , drv .RsyncClient .RemoteHost )
22
+ }
19
23
}
20
24
21
- // TODO: test RunCommand machinery
25
+ func TestString (t * testing.T ) {
26
+ drv , _ := NewDriver ("some-user@some-host:1234" )
27
+ assert .Equal (t , "SSH driver (host: some-host)" , drv .String ())
28
+ }
You can’t perform that action at this time.
0 commit comments