forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_req_factory.go
149 lines (115 loc) · 3.83 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package requirements
import (
"github.com/cloudfoundry/cli/cf/models"
"github.com/cloudfoundry/cli/cf/requirements"
)
type FakeReqFactory struct {
ApplicationName string
Application models.Application
ServiceInstanceName string
ServiceInstance models.ServiceInstance
LoginSuccess bool
ApiEndpointSuccess bool
ValidAccessTokenSuccess bool
TargetedSpaceSuccess bool
TargetedOrgSuccess bool
BuildpackSuccess bool
SpaceName string
Space models.Space
OrganizationName string
Organization models.Organization
OrganizationFields models.OrganizationFields
RouteHost string
RouteDomain string
Route models.Route
DomainName string
Domain models.DomainFields
UserUsername string
UserFields models.UserFields
Buildpack models.Buildpack
MinCCApiVersionCommandName string
MinCCApiVersionMajor int
MinCCApiVersionMinor int
MinCCApiVersionPatch int
}
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) 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}
}
func (f *FakeReqFactory) NewApiEndpointRequirement() requirements.Requirement {
return FakeRequirement{f, f.ApiEndpointSuccess}
}
func (f *FakeReqFactory) NewMinCCApiVersionRequirement(commandName string, major, minor, patch int) requirements.Requirement {
f.MinCCApiVersionCommandName = commandName
f.MinCCApiVersionMajor = major
f.MinCCApiVersionMinor = minor
f.MinCCApiVersionPatch = patch
return FakeRequirement{f, true}
}
type FakeRequirement struct {
factory *FakeReqFactory
success bool
}
func (r FakeRequirement) Execute() (success bool) {
return r.success
}
func (r FakeRequirement) GetApplication() models.Application {
return r.factory.Application
}
func (r FakeRequirement) GetServiceInstance() models.ServiceInstance {
return r.factory.ServiceInstance
}
func (r FakeRequirement) GetSpace() models.Space {
return r.factory.Space
}
func (r FakeRequirement) GetOrganization() models.Organization {
return r.factory.Organization
}
func (r FakeRequirement) GetOrganizationFields() models.OrganizationFields {
return r.factory.OrganizationFields
}
func (r FakeRequirement) GetRoute() models.Route {
return r.factory.Route
}
func (r FakeRequirement) GetDomain() models.DomainFields {
return r.factory.Domain
}
func (r FakeRequirement) GetUser() models.UserFields {
return r.factory.UserFields
}
func (r FakeRequirement) GetBuildpack() models.Buildpack {
return r.factory.Buildpack
}