-
Notifications
You must be signed in to change notification settings - Fork 161
/
fake_downloader.go
82 lines (72 loc) · 2.33 KB
/
fake_downloader.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
// This file was generated by counterfeiter
package cmdfakes
import (
"sync"
"github.com/cloudfoundry/bosh-cli/cmd"
)
type FakeDownloader struct {
DownloadStub func(blobstoreID, sha1, prefix, dstDirPath string) error
downloadMutex sync.RWMutex
downloadArgsForCall []struct {
blobstoreID string
sha1 string
prefix string
dstDirPath string
}
downloadReturns struct {
result1 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakeDownloader) Download(blobstoreID string, sha1 string, prefix string, dstDirPath string) error {
fake.downloadMutex.Lock()
fake.downloadArgsForCall = append(fake.downloadArgsForCall, struct {
blobstoreID string
sha1 string
prefix string
dstDirPath string
}{blobstoreID, sha1, prefix, dstDirPath})
fake.recordInvocation("Download", []interface{}{blobstoreID, sha1, prefix, dstDirPath})
fake.downloadMutex.Unlock()
if fake.DownloadStub != nil {
return fake.DownloadStub(blobstoreID, sha1, prefix, dstDirPath)
} else {
return fake.downloadReturns.result1
}
}
func (fake *FakeDownloader) DownloadCallCount() int {
fake.downloadMutex.RLock()
defer fake.downloadMutex.RUnlock()
return len(fake.downloadArgsForCall)
}
func (fake *FakeDownloader) DownloadArgsForCall(i int) (string, string, string, string) {
fake.downloadMutex.RLock()
defer fake.downloadMutex.RUnlock()
return fake.downloadArgsForCall[i].blobstoreID, fake.downloadArgsForCall[i].sha1, fake.downloadArgsForCall[i].prefix, fake.downloadArgsForCall[i].dstDirPath
}
func (fake *FakeDownloader) DownloadReturns(result1 error) {
fake.DownloadStub = nil
fake.downloadReturns = struct {
result1 error
}{result1}
}
func (fake *FakeDownloader) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.downloadMutex.RLock()
defer fake.downloadMutex.RUnlock()
return fake.invocations
}
func (fake *FakeDownloader) 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 _ cmd.Downloader = new(FakeDownloader)