forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_writer.go
85 lines (75 loc) · 2.14 KB
/
fake_writer.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
// This file was generated by counterfeiter
package releasefakes
import (
"sync"
"github.com/cloudfoundry/bosh-cli/release"
)
type FakeWriter struct {
WriteStub func(release.Release, []string) (string, error)
writeMutex sync.RWMutex
writeArgsForCall []struct {
arg1 release.Release
arg2 []string
}
writeReturns struct {
result1 string
result2 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakeWriter) Write(arg1 release.Release, arg2 []string) (string, error) {
var arg2Copy []string
if arg2 != nil {
arg2Copy = make([]string, len(arg2))
copy(arg2Copy, arg2)
}
fake.writeMutex.Lock()
fake.writeArgsForCall = append(fake.writeArgsForCall, struct {
arg1 release.Release
arg2 []string
}{arg1, arg2Copy})
fake.recordInvocation("Write", []interface{}{arg1, arg2Copy})
fake.writeMutex.Unlock()
if fake.WriteStub != nil {
return fake.WriteStub(arg1, arg2)
} else {
return fake.writeReturns.result1, fake.writeReturns.result2
}
}
func (fake *FakeWriter) WriteCallCount() int {
fake.writeMutex.RLock()
defer fake.writeMutex.RUnlock()
return len(fake.writeArgsForCall)
}
func (fake *FakeWriter) WriteArgsForCall(i int) (release.Release, []string) {
fake.writeMutex.RLock()
defer fake.writeMutex.RUnlock()
return fake.writeArgsForCall[i].arg1, fake.writeArgsForCall[i].arg2
}
func (fake *FakeWriter) WriteReturns(result1 string, result2 error) {
fake.WriteStub = nil
fake.writeReturns = struct {
result1 string
result2 error
}{result1, result2}
}
func (fake *FakeWriter) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.writeMutex.RLock()
defer fake.writeMutex.RUnlock()
return fake.invocations
}
func (fake *FakeWriter) 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)
}
var _ release.Writer = new(FakeWriter)