@@ -3,19 +3,16 @@ package fakes
3
3
import "github.com/pivotal-cf/brokerapi"
4
4
5
5
type FakeServiceBroker struct {
6
- ProvisionDetails brokerapi.ProvisionDetails
7
- AcceptsIncomplete bool
6
+ ProvisionDetails brokerapi.ProvisionDetails
8
7
9
- ProvisionedInstanceIDs []string
10
- DeprovisionedInstanceIDs []string
11
- AysncProvisionInstanceIds []string
8
+ ProvisionedInstanceIDs []string
9
+ DeprovisionedInstanceIDs []string
12
10
13
11
BoundInstanceIDs []string
14
12
BoundBindingIDs []string
15
13
BoundBindingDetails brokerapi.BindDetails
16
14
17
15
InstanceLimit int
18
- SupportsAsync brokerapi.IsAsync
19
16
20
17
ProvisionError error
21
18
BindError error
@@ -29,6 +26,7 @@ type FakeServiceBroker struct {
29
26
30
27
type FakeAsyncServiceBroker struct {
31
28
FakeServiceBroker
29
+ ShouldProvisionAsync bool
32
30
}
33
31
34
32
type FakeAsyncOnlyServiceBroker struct {
@@ -76,57 +74,47 @@ func (fakeBroker *FakeServiceBroker) Services() []brokerapi.Service {
76
74
}
77
75
}
78
76
79
- func (fakeBroker * FakeServiceBroker ) ProvisionAsync (instanceID string , details brokerapi.ProvisionDetails ) (brokerapi.IsAsync , error ) {
80
- fakeBroker .ProvisionDetails = details
81
- fakeBroker .AysncProvisionInstanceIds = append (fakeBroker .AysncProvisionInstanceIds , instanceID )
82
- return fakeBroker .SupportsAsync , nil
83
- }
84
-
85
- func (fakeBroker * FakeServiceBroker ) ProvisionSync (instanceID string , details brokerapi.ProvisionDetails ) error {
77
+ func (fakeBroker * FakeServiceBroker ) Provision (instanceID string , details brokerapi.ProvisionDetails , asyncAllowed bool ) (brokerapi.IsAsync , error ) {
86
78
fakeBroker .BrokerCalled = true
87
79
88
80
if fakeBroker .ProvisionError != nil {
89
- return fakeBroker .ProvisionError
81
+ return false , fakeBroker .ProvisionError
90
82
}
91
83
92
84
if len (fakeBroker .ProvisionedInstanceIDs ) >= fakeBroker .InstanceLimit {
93
- return brokerapi .ErrInstanceLimitMet
85
+ return false , brokerapi .ErrInstanceLimitMet
94
86
}
95
87
96
88
if sliceContains (instanceID , fakeBroker .ProvisionedInstanceIDs ) {
97
- return brokerapi .ErrInstanceAlreadyExists
89
+ return false , brokerapi .ErrInstanceAlreadyExists
98
90
}
99
91
100
92
fakeBroker .ProvisionDetails = details
101
93
fakeBroker .ProvisionedInstanceIDs = append (fakeBroker .ProvisionedInstanceIDs , instanceID )
102
- return nil
94
+ return false , nil
103
95
}
104
96
105
- func (fakeBroker * FakeAsyncServiceBroker ) ProvisionSync (instanceID string , details brokerapi.ProvisionDetails ) error {
97
+ func (fakeBroker * FakeAsyncServiceBroker ) Provision (instanceID string , details brokerapi.ProvisionDetails , asyncAllowed bool ) (brokerapi. IsAsync , error ) {
106
98
fakeBroker .BrokerCalled = true
107
99
108
100
if fakeBroker .ProvisionError != nil {
109
- return fakeBroker .ProvisionError
101
+ return false , fakeBroker .ProvisionError
110
102
}
111
103
112
104
if len (fakeBroker .ProvisionedInstanceIDs ) >= fakeBroker .InstanceLimit {
113
- return brokerapi .ErrInstanceLimitMet
105
+ return false , brokerapi .ErrInstanceLimitMet
114
106
}
115
107
116
108
if sliceContains (instanceID , fakeBroker .ProvisionedInstanceIDs ) {
117
- return brokerapi .ErrInstanceAlreadyExists
109
+ return false , brokerapi .ErrInstanceAlreadyExists
118
110
}
119
111
120
112
fakeBroker .ProvisionDetails = details
121
113
fakeBroker .ProvisionedInstanceIDs = append (fakeBroker .ProvisionedInstanceIDs , instanceID )
122
- return nil
123
- }
124
-
125
- func (fakeBroker * FakeAsyncOnlyServiceBroker ) ProvisionSync (instanceID string , details brokerapi.ProvisionDetails ) error {
126
- return brokerapi .ErrAsyncRequired
114
+ return brokerapi .IsAsync (fakeBroker .ShouldProvisionAsync ), nil
127
115
}
128
116
129
- func (fakeBroker * FakeAsyncOnlyServiceBroker ) ProvisionAsync (instanceID string , details brokerapi.ProvisionDetails ) (brokerapi.IsAsync , error ) {
117
+ func (fakeBroker * FakeAsyncOnlyServiceBroker ) Provision (instanceID string , details brokerapi.ProvisionDetails , asyncAllowed bool ) (brokerapi.IsAsync , error ) {
130
118
fakeBroker .BrokerCalled = true
131
119
132
120
if fakeBroker .ProvisionError != nil {
@@ -141,9 +129,13 @@ func (fakeBroker *FakeAsyncOnlyServiceBroker) ProvisionAsync(instanceID string,
141
129
return false , brokerapi .ErrInstanceAlreadyExists
142
130
}
143
131
132
+ if ! asyncAllowed {
133
+ return true , brokerapi .ErrAsyncRequired
134
+ }
135
+
144
136
fakeBroker .ProvisionDetails = details
145
137
fakeBroker .ProvisionedInstanceIDs = append (fakeBroker .ProvisionedInstanceIDs , instanceID )
146
- return fakeBroker . SupportsAsync , nil
138
+ return true , nil
147
139
}
148
140
149
141
func (fakeBroker * FakeServiceBroker ) Deprovision (instanceID string ) error {
0 commit comments