forked from cloudfoundry/bosh-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ssh_cli.go
48 lines (37 loc) · 912 Bytes
/
ssh_cli.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
package fakes
import "os/exec"
type SSHCLI struct {
RunCall struct {
CallCount int
Receives [][]string
Returns []error
}
StartCall struct {
CallCount int
Receives [][]string
Returns []SSHStartReturn
}
}
type SSHRunReceive struct {
Args []string
}
type SSHStartReturn struct {
Cmd *exec.Cmd
Error error
}
func (s *SSHCLI) Run(args []string) error {
s.RunCall.CallCount++
s.RunCall.Receives = append(s.RunCall.Receives, args)
if len(s.RunCall.Returns) < s.RunCall.CallCount {
return nil
}
return s.RunCall.Returns[s.RunCall.CallCount-1]
}
func (s *SSHCLI) Start(args []string) (*exec.Cmd, error) {
s.StartCall.CallCount++
s.StartCall.Receives = append(s.StartCall.Receives, args)
if len(s.StartCall.Returns) < s.StartCall.CallCount {
return nil, nil
}
return s.StartCall.Returns[s.StartCall.CallCount-1].Cmd, s.StartCall.Returns[s.StartCall.CallCount-1].Error
}