forked from cloudfoundry/bosh-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bosh_cli.go
113 lines (100 loc) · 2.69 KB
/
bosh_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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package fakes
import (
"io"
"sync"
)
type BOSHCLI struct {
GetBOSHPathCall struct {
CallCount int
Returns struct {
Path string
}
}
RunStub func(stdout io.Writer, workingDirectory string, args []string) error
runMutex sync.RWMutex
runArgsForCall []struct {
stdout io.Writer
workingDirectory string
args []string
}
runReturns struct {
result1 error
}
runReturnsOnCall map[int]struct {
result1 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *BOSHCLI) GetBOSHPath() string {
fake.GetBOSHPathCall.CallCount++
return fake.GetBOSHPathCall.Returns.Path
}
func (fake *BOSHCLI) Run(stdout io.Writer, workingDirectory string, args []string) error {
var argsCopy []string
if args != nil {
argsCopy = make([]string, len(args))
copy(argsCopy, args)
}
fake.runMutex.Lock()
ret, specificReturn := fake.runReturnsOnCall[len(fake.runArgsForCall)]
fake.runArgsForCall = append(fake.runArgsForCall, struct {
stdout io.Writer
workingDirectory string
args []string
}{stdout, workingDirectory, argsCopy})
fake.recordInvocation("Run", []interface{}{stdout, workingDirectory, argsCopy})
fake.runMutex.Unlock()
if fake.RunStub != nil {
return fake.RunStub(stdout, workingDirectory, args)
}
if specificReturn {
return ret.result1
}
return fake.runReturns.result1
}
func (fake *BOSHCLI) RunCallCount() int {
fake.runMutex.RLock()
defer fake.runMutex.RUnlock()
return len(fake.runArgsForCall)
}
func (fake *BOSHCLI) RunArgsForCall(i int) (io.Writer, string, []string) {
fake.runMutex.RLock()
defer fake.runMutex.RUnlock()
return fake.runArgsForCall[i].stdout, fake.runArgsForCall[i].workingDirectory, fake.runArgsForCall[i].args
}
func (fake *BOSHCLI) RunReturns(result1 error) {
fake.RunStub = nil
fake.runReturns = struct {
result1 error
}{result1}
}
func (fake *BOSHCLI) RunReturnsOnCall(i int, result1 error) {
fake.RunStub = nil
if fake.runReturnsOnCall == nil {
fake.runReturnsOnCall = make(map[int]struct {
result1 error
})
}
fake.runReturnsOnCall[i] = struct {
result1 error
}{result1}
}
func (fake *BOSHCLI) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.runMutex.RLock()
defer fake.runMutex.RUnlock()
return fake.invocations
}
func (fake *BOSHCLI) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}