forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_service_broker_repo.go
89 lines (71 loc) · 2.16 KB
/
fake_service_broker_repo.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
package fakes
import (
"github.com/cloudfoundry/cli/cf/errors"
"github.com/cloudfoundry/cli/cf/models"
)
type FakeServiceBrokerRepo struct {
FindByNameName string
FindByNameServiceBroker models.ServiceBroker
FindByNameNotFound bool
FindByGuidGuid string
FindByGuidServiceBroker models.ServiceBroker
FindByGuidNotFound bool
CreateName string
CreateUrl string
CreateUsername string
CreatePassword string
UpdatedServiceBroker models.ServiceBroker
RenamedServiceBrokerGuid string
RenamedServiceBrokerName string
DeletedServiceBrokerGuid string
ServiceBrokers []models.ServiceBroker
ListErr bool
}
func (repo *FakeServiceBrokerRepo) FindByName(name string) (serviceBroker models.ServiceBroker, apiErr error) {
repo.FindByNameName = name
serviceBroker = repo.FindByNameServiceBroker
if repo.FindByNameNotFound {
apiErr = errors.NewModelNotFoundError("Service Broker", name)
}
return
}
func (repo *FakeServiceBrokerRepo) FindByGuid(guid string) (serviceBroker models.ServiceBroker, apiErr error) {
repo.FindByGuidGuid = guid
serviceBroker = repo.FindByGuidServiceBroker
if repo.FindByGuidNotFound {
apiErr = errors.NewModelNotFoundError("Service Broker", guid)
}
return
}
func (repo *FakeServiceBrokerRepo) ListServiceBrokers(callback func(broker models.ServiceBroker) bool) error {
for _, broker := range repo.ServiceBrokers {
if !callback(broker) {
break
}
}
if repo.ListErr {
return errors.New("Error finding service brokers")
} else {
return nil
}
}
func (repo *FakeServiceBrokerRepo) Create(name, url, username, password string) (apiErr error) {
repo.CreateName = name
repo.CreateUrl = url
repo.CreateUsername = username
repo.CreatePassword = password
return
}
func (repo *FakeServiceBrokerRepo) Update(serviceBroker models.ServiceBroker) (apiErr error) {
repo.UpdatedServiceBroker = serviceBroker
return
}
func (repo *FakeServiceBrokerRepo) Rename(guid, name string) (apiErr error) {
repo.RenamedServiceBrokerGuid = guid
repo.RenamedServiceBrokerName = name
return
}
func (repo *FakeServiceBrokerRepo) Delete(guid string) (apiErr error) {
repo.DeletedServiceBrokerGuid = guid
return
}