forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_req_factory.go
130 lines (99 loc) · 3.06 KB
/
fake_req_factory.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package requirements
import (
"cf"
"cf/requirements"
)
type FakeReqFactory struct {
ApplicationName string
Application cf.Application
ServiceInstanceName string
ServiceInstance cf.ServiceInstance
LoginSuccess bool
ValidAccessTokenSuccess bool
TargetedSpaceSuccess bool
TargetedOrgSuccess bool
BuildpackSuccess bool
SpaceName string
Space cf.Space
OrganizationName string
Organization cf.Organization
RouteHost string
RouteDomain string
Route cf.Route
DomainName string
Domain cf.Domain
UserUsername string
User cf.User
Buildpack cf.Buildpack
}
func (f *FakeReqFactory) NewApplicationRequirement(name string) requirements.ApplicationRequirement {
f.ApplicationName = name
return FakeRequirement{f, true}
}
func (f *FakeReqFactory) NewServiceInstanceRequirement(name string) requirements.ServiceInstanceRequirement {
f.ServiceInstanceName = name
return FakeRequirement{f, true}
}
func (f *FakeReqFactory) NewLoginRequirement() requirements.Requirement {
return FakeRequirement{f, f.LoginSuccess}
}
func (f *FakeReqFactory) NewValidAccessTokenRequirement() requirements.Requirement {
return FakeRequirement{f, f.ValidAccessTokenSuccess}
}
func (f *FakeReqFactory) NewTargetedSpaceRequirement() requirements.Requirement {
return FakeRequirement{f, f.TargetedSpaceSuccess}
}
func (f *FakeReqFactory) NewTargetedOrgRequirement() requirements.TargetedOrgRequirement {
return FakeRequirement{f, f.TargetedOrgSuccess}
}
func (f *FakeReqFactory) NewSpaceRequirement(name string) requirements.SpaceRequirement {
f.SpaceName = name
return FakeRequirement{f, true}
}
func (f *FakeReqFactory) NewOrganizationRequirement(name string) requirements.OrganizationRequirement {
f.OrganizationName = name
return FakeRequirement{f, true}
}
func (f *FakeReqFactory) NewDomainRequirement(name string) requirements.DomainRequirement {
f.DomainName = name
return FakeRequirement{f, true}
}
func (f *FakeReqFactory) NewUserRequirement(username string) requirements.UserRequirement {
f.UserUsername = username
return FakeRequirement{f, true}
}
func (f *FakeReqFactory) NewBuildpackRequirement(buildpack string) requirements.BuildpackRequirement {
f.Buildpack.Name = buildpack
return FakeRequirement{f, f.BuildpackSuccess}
}
type FakeRequirement struct {
factory *FakeReqFactory
success bool
}
func (r FakeRequirement) Execute() (success bool) {
return r.success
}
func (r FakeRequirement) GetApplication() cf.Application {
return r.factory.Application
}
func (r FakeRequirement) GetServiceInstance() cf.ServiceInstance {
return r.factory.ServiceInstance
}
func (r FakeRequirement) GetSpace() cf.Space {
return r.factory.Space
}
func (r FakeRequirement) GetOrganization() cf.Organization {
return r.factory.Organization
}
func (r FakeRequirement) GetRoute() cf.Route {
return r.factory.Route
}
func (r FakeRequirement) GetDomain() cf.Domain {
return r.factory.Domain
}
func (r FakeRequirement) GetUser() cf.User {
return r.factory.User
}
func (r FakeRequirement) GetBuildpack() cf.Buildpack {
return r.factory.Buildpack
}