This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
service.go
80 lines (67 loc) · 2.41 KB
/
service.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
// +build !production
package fakeclient
import (
"github.com/secrethub/secrethub-go/internals/api"
"github.com/secrethub/secrethub-go/pkg/secrethub/credentials"
)
// ServiceService is a mock of the ServiceService interface.
type ServiceService struct {
Creator ServiceCreater
Deleter ServiceDeleter
Getter ServiceGetter
Lister RepoServiceLister
AWSService *ServiceAWSService
}
// Create implements the ServiceService interface Create function.
func (s *ServiceService) Create(path string, description string, credentialCreator credentials.Creator) (*api.Service, error) {
return s.Creator.Create(path, description, credentialCreator)
}
// Delete implements the ServiceService interface Delete function.
func (s *ServiceService) Delete(id string) (*api.RevokeRepoResponse, error) {
return s.Deleter.Delete(id)
}
// Get implements the ServiceService interface Get function.
func (s *ServiceService) Get(id string) (*api.Service, error) {
return s.Getter.Get(id)
}
// List implements the ServiceService interface List function.
func (s *ServiceService) List(path string) ([]*api.Service, error) {
return s.Lister.List(path)
}
// ServiceCreater mocks the Create function.
type ServiceCreater struct {
ArgPath string
ArgDescription string
ArgCredentialCreator credentials.Creator
ReturnsService *api.Service
Err error
}
// Create saves the arguments it was called with and returns the mocked response.
func (c *ServiceCreater) Create(path string, description string, credentialCreator credentials.Creator) (*api.Service, error) {
c.ArgPath = path
c.ArgDescription = description
c.ArgCredentialCreator = credentialCreator
return c.ReturnsService, c.Err
}
// ServiceDeleter mocks the Delete function.
type ServiceDeleter struct {
ArgID string
ReturnsRevokeResponse *api.RevokeRepoResponse
Err error
}
// Delete saves the arguments it was called with and returns the mocked response.
func (d *ServiceDeleter) Delete(id string) (*api.RevokeRepoResponse, error) {
d.ArgID = id
return d.ReturnsRevokeResponse, d.Err
}
// ServiceGetter mocks the Get function.
type ServiceGetter struct {
ArgID string
ReturnsService *api.Service
Err error
}
// Get saves the arguments it was called with and returns the mocked response.
func (g *ServiceGetter) Get(id string) (*api.Service, error) {
g.ArgID = id
return g.ReturnsService, g.Err
}