Skip to content
This repository was archived by the owner on May 18, 2021. It is now read-only.

Commit a763a43

Browse files
committed
Test the SSH driver
1 parent 56dd8b8 commit a763a43

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

driver/ssh/driver.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010

1111
// Driver is a driver based on SSH.
1212
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
1616
}
1717

1818
// NewDriver creates a new SSH driver that communicates with the given host.
@@ -31,15 +31,15 @@ func NewDriver(host string) (*Driver, error) {
3131

3232
// RunCommand runs the specified command on the host.
3333
func (drv Driver) RunCommand(args []string) error {
34-
return drv.sshClient.RunCommand(args)
34+
return drv.SSHClient.RunCommand(args)
3535
}
3636

3737
// Upload copies files to the host.
3838
func (drv Driver) Upload(dst string, src ...string) error {
39-
return drv.rsyncClient.Copy(dst, src...)
39+
return drv.RsyncClient.Copy(dst, src...)
4040
}
4141

4242
// String returns the driver's name.
4343
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)
4545
}

driver/ssh/driver_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ func TestDriverInterface(t *testing.T) {
1212
assert.Implements(t, (*driver.Driver)(nil), new(Driver))
1313
}
1414

15-
func TestString(t *testing.T) {
15+
func TestNewDriver(t *testing.T) {
1616
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+
}
1923
}
2024

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+
}

0 commit comments

Comments
 (0)