/
image_service_client.go
50 lines (46 loc) · 994 Bytes
/
image_service_client.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
package fakes
import (
"sync"
"github.com/gophercloud/gophercloud/openstack/imageservice/v2/images"
)
type ImageServiceClient struct {
DeleteCall struct {
sync.Mutex
CallCount int
Receives struct {
Id string
}
Returns struct {
Error error
}
Stub func(string) error
}
ListCall struct {
sync.Mutex
CallCount int
Returns struct {
ImageSlice []images.Image
Error error
}
Stub func() ([]images.Image, error)
}
}
func (f *ImageServiceClient) Delete(param1 string) error {
f.DeleteCall.Lock()
defer f.DeleteCall.Unlock()
f.DeleteCall.CallCount++
f.DeleteCall.Receives.Id = param1
if f.DeleteCall.Stub != nil {
return f.DeleteCall.Stub(param1)
}
return f.DeleteCall.Returns.Error
}
func (f *ImageServiceClient) List() ([]images.Image, error) {
f.ListCall.Lock()
defer f.ListCall.Unlock()
f.ListCall.CallCount++
if f.ListCall.Stub != nil {
return f.ListCall.Stub()
}
return f.ListCall.Returns.ImageSlice, f.ListCall.Returns.Error
}