forked from tw4dl/libretto
/
mock_ssh.go
83 lines (72 loc) · 1.75 KB
/
mock_ssh.go
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
// Copyright 2015 Apcera Inc. All rights reserved.
package ssh
import (
"io"
"time"
)
// Connect calls the mocked connect.
func (c *MockSSHClient) Connect() error {
if c.MockConnect != nil {
return c.MockConnect()
}
return ErrNotImplemented
}
// Disconnect calls the mocked disconnect.
func (c *MockSSHClient) Disconnect() {
if c.MockDisconnect != nil {
c.MockDisconnect()
return
}
return
}
// Download calls the mocked download.
func (c *MockSSHClient) Download(src io.WriteCloser, dst string) error {
if c.MockDownload != nil {
return c.MockDownload(src, dst)
}
return ErrNotImplemented
}
// Run calls the mocked run
func (c *MockSSHClient) Run(command string, stdout io.Writer, stderr io.Writer) error {
if c.MockRun != nil {
return c.MockRun(command, stdout, stderr)
}
return ErrNotImplemented
}
// Upload calls the mocked upload
func (c *MockSSHClient) Upload(src io.Reader, dst string, mode uint32) error {
if c.MockUpload != nil {
return c.MockUpload(src, dst, mode)
}
return ErrNotImplemented
}
// Validate calls the mocked validate.
func (c *MockSSHClient) Validate() error {
if c.MockValidate != nil {
return c.MockValidate()
}
return ErrNotImplemented
}
// WaitForSSH calls the mocked WaitForSSH
func (c *MockSSHClient) WaitForSSH(maxWait time.Duration) error {
if c.MockWaitForSSH != nil {
return c.MockWaitForSSH(maxWait)
}
return ErrNotImplemented
}
// SetSSHPrivateKey calls the mocked SetSSHPrivateKey
func (c *MockSSHClient) SetSSHPrivateKey(s string) {
if c.MockSetSSHPrivateKey != nil {
c.MockSetSSHPrivateKey(s)
return
}
return
}
// SetSSHPassword calls the mocked SetSSHPassword
func (c *MockSSHClient) SetSSHPassword(s string) {
if c.MockSetSSHPassword != nil {
c.MockSetSSHPassword(s)
return
}
return
}