@@ -35,27 +35,21 @@ var _ = Describe("New Remediation command", func() {
35
35
mockCtrl * gomock.Controller
36
36
mockOcmInterface * ocmMock.MockOCMInterface
37
37
mockClientUtil * backplaneapiMock.MockClientUtils
38
- //mockClient *mocks.MockClientInterface
39
- mockClientWithResp * mocks.MockClientWithResponsesInterface
40
- //mockCluster *cmv1.Cluster
41
-
42
- testClusterID string
43
- trueClusterID string
44
- testToken string
45
- testRemediationName string
46
- testProxyURI string
47
- fakeResp * http.Response
48
- bpConfigPath string
49
- backplaneAPIURI string
50
- ocmEnv * cmv1.Environment
51
- createRemediationResponse * BackplaneApi.CreateRemediationResponse
52
- deleteRemediationResponse * BackplaneApi.DeleteRemediationResponse
38
+ mockClient * mocks.MockClientInterface
39
+
40
+ testClusterID string
41
+ trueClusterID string
42
+ testToken string
43
+ testRemediationName string
44
+ fakeResp * http.Response
45
+ bpConfigPath string
46
+ backplaneAPIURI string
47
+ ocmEnv * cmv1.Environment
53
48
)
54
49
55
50
BeforeEach (func () {
56
51
mockCtrl = gomock .NewController (GinkgoT ())
57
- mockClientWithResp = mocks .NewMockClientWithResponsesInterface (mockCtrl )
58
- //ockClient = mocks.NewMockClientInterface(mockCtrl)
52
+ mockClient = mocks .NewMockClientInterface (mockCtrl )
59
53
60
54
err := utils .CreateTempKubeConfig (nil )
61
55
Expect (err ).To (BeNil ())
@@ -66,7 +60,7 @@ var _ = Describe("New Remediation command", func() {
66
60
mockClientUtil = backplaneapiMock .NewMockClientUtils (mockCtrl )
67
61
backplaneapi .DefaultClientUtils = mockClientUtil
68
62
69
- mockClientWithResp .EXPECT ().LoginClusterWithResponse (gomock .Any (), gomock .Any ()).Return (nil , nil ).Times (0 )
63
+ mockClient .EXPECT ().LoginCluster (gomock .Any (), gomock .Any ()).Return (nil , nil ).Times (0 )
70
64
71
65
_ = clientcmd .ModifyConfig (clientcmd .NewDefaultPathOptions (), api.Config {}, true )
72
66
clientcmd .UseModifyConfigLock = false
@@ -75,30 +69,13 @@ var _ = Describe("New Remediation command", func() {
75
69
76
70
ocmEnv , _ = cmv1 .NewEnvironment ().BackplaneURL ("https://api.example.com" ).Build ()
77
71
78
- //mockCluster = &cmv1.Cluster{}
79
-
80
- //backplaneConfiguration = config.BackplaneConfiguration{URL: backplaneAPIURI}
81
-
82
72
fakeResp = & http.Response {
83
73
Body : MakeIoReader (`{"proxy_uri":"proxy", "statusCode":200, "message":"msg"}` ),
84
74
Header : map [string ][]string {},
85
75
StatusCode : http .StatusOK ,
86
76
}
87
77
fakeResp .Header .Add ("Content-Type" , "json" )
88
78
89
- testProxyURI = "http://proxy.example.com/"
90
-
91
- createRemediationResponse = & BackplaneApi.CreateRemediationResponse {
92
- HTTPResponse : fakeResp ,
93
- Body : []byte ("" ),
94
- JSON200 : & BackplaneApi.LoginResponse {ProxyUri : & testProxyURI },
95
- }
96
-
97
- deleteRemediationResponse = & BackplaneApi.DeleteRemediationResponse {
98
- HTTPResponse : fakeResp ,
99
- Body : []byte ("" ),
100
- }
101
-
102
79
testClusterID = "test123"
103
80
trueClusterID = "trueID123"
104
81
backplaneAPIURI = "https://shard.apps.example.com/"
@@ -126,8 +103,8 @@ var _ = Describe("New Remediation command", func() {
126
103
mockOcmInterface .EXPECT ().GetOCMAccessToken ().Return (& testToken , nil )
127
104
mockOcmInterface .EXPECT ().IsClusterHibernating (gomock .Eq (trueClusterID )).Return (false , nil ).AnyTimes ()
128
105
129
- mockClientUtil .EXPECT ().MakeBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (mockClientWithResp , nil )
130
- mockClientWithResp .EXPECT ().CreateRemediationWithResponse (context .TODO (), trueClusterID , & BackplaneApi.CreateRemediationParams {Remediation : testRemediationName }).Return (createRemediationResponse , nil )
106
+ mockClientUtil .EXPECT ().MakeRawBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (mockClient , nil )
107
+ mockClient .EXPECT ().CreateRemediation (context .TODO (), trueClusterID , & BackplaneApi.CreateRemediationParams {Remediation : testRemediationName }).Return (fakeResp , nil )
131
108
132
109
err := runCreateRemediation ([]string {testRemediationName }, testClusterID , backplaneAPIURI )
133
110
@@ -140,8 +117,8 @@ var _ = Describe("New Remediation command", func() {
140
117
mockOcmInterface .EXPECT ().GetOCMAccessToken ().Return (& testToken , nil )
141
118
mockOcmInterface .EXPECT ().IsClusterHibernating (gomock .Eq (trueClusterID )).Return (false , nil ).AnyTimes ()
142
119
143
- mockClientUtil .EXPECT ().MakeBackplaneAPIClientWithAccessToken ("http://uri2.example.com" , testToken ).Return (mockClientWithResp , nil )
144
- mockClientWithResp .EXPECT ().CreateRemediationWithResponse (context .TODO (), trueClusterID , & BackplaneApi.CreateRemediationParams {Remediation : testRemediationName }).Return (createRemediationResponse , nil )
120
+ mockClientUtil .EXPECT ().MakeRawBackplaneAPIClientWithAccessToken ("http://uri2.example.com" , testToken ).Return (mockClient , nil )
121
+ mockClient .EXPECT ().CreateRemediation (context .TODO (), trueClusterID , & BackplaneApi.CreateRemediationParams {Remediation : testRemediationName }).Return (fakeResp , nil )
145
122
146
123
err := runCreateRemediation ([]string {testRemediationName }, testClusterID , "http://uri2.example.com" )
147
124
@@ -158,8 +135,8 @@ var _ = Describe("New Remediation command", func() {
158
135
mockOcmInterface .EXPECT ().GetOCMAccessToken ().Return (& testToken , nil )
159
136
mockOcmInterface .EXPECT ().IsClusterHibernating (gomock .Eq (trueClusterID )).Return (false , nil ).AnyTimes ()
160
137
161
- mockClientUtil .EXPECT ().MakeBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (mockClientWithResp , nil )
162
- mockClientWithResp .EXPECT ().CreateRemediationWithResponse (context .TODO (), trueClusterID , & BackplaneApi.CreateRemediationParams {Remediation : testRemediationName }).Return (createRemediationResponse , nil )
138
+ mockClientUtil .EXPECT ().MakeRawBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (mockClient , nil )
139
+ mockClient .EXPECT ().CreateRemediation (context .TODO (), trueClusterID , & BackplaneApi.CreateRemediationParams {Remediation : testRemediationName }).Return (fakeResp , nil )
163
140
164
141
err := runCreateRemediation ([]string {testRemediationName }, testClusterID , backplaneAPIURI )
165
142
@@ -183,7 +160,7 @@ var _ = Describe("New Remediation command", func() {
183
160
mockOcmInterface .EXPECT ().GetOCMAccessToken ().Return (& testToken , nil )
184
161
mockOcmInterface .EXPECT ().IsClusterHibernating (gomock .Eq (trueClusterID )).Return (false , nil ).AnyTimes ()
185
162
186
- mockClientUtil .EXPECT ().MakeBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (nil , errors .New ("err" ))
163
+ mockClientUtil .EXPECT ().MakeRawBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (nil , errors .New ("err" ))
187
164
188
165
err := runCreateRemediation ([]string {testRemediationName }, testClusterID , backplaneAPIURI )
189
166
@@ -208,8 +185,8 @@ var _ = Describe("New Remediation command", func() {
208
185
mockOcmInterface .EXPECT ().GetOCMAccessToken ().Return (& testToken , nil )
209
186
mockOcmInterface .EXPECT ().IsClusterHibernating (gomock .Eq (trueClusterID )).Return (false , nil ).AnyTimes ()
210
187
211
- mockClientUtil .EXPECT ().MakeBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (mockClientWithResp , nil )
212
- mockClientWithResp .EXPECT ().DeleteRemediationWithResponse (context .TODO (), trueClusterID , & BackplaneApi.DeleteRemediationParams {Remediation : & testRemediationName }).Return (deleteRemediationResponse , nil )
188
+ mockClientUtil .EXPECT ().MakeRawBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (mockClient , nil )
189
+ mockClient .EXPECT ().DeleteRemediation (context .TODO (), trueClusterID , & BackplaneApi.DeleteRemediationParams {Remediation : & testRemediationName }).Return (fakeResp , nil )
213
190
214
191
err := runDeleteRemediation ([]string {testRemediationName }, testClusterID , backplaneAPIURI )
215
192
@@ -222,8 +199,8 @@ var _ = Describe("New Remediation command", func() {
222
199
mockOcmInterface .EXPECT ().GetOCMAccessToken ().Return (& testToken , nil )
223
200
mockOcmInterface .EXPECT ().IsClusterHibernating (gomock .Eq (trueClusterID )).Return (false , nil ).AnyTimes ()
224
201
225
- mockClientUtil .EXPECT ().MakeBackplaneAPIClientWithAccessToken ("https://uri2.example.com/" , testToken ).Return (mockClientWithResp , nil )
226
- mockClientWithResp .EXPECT ().DeleteRemediationWithResponse (context .TODO (), trueClusterID , & BackplaneApi.DeleteRemediationParams {Remediation : & testRemediationName }).Return (deleteRemediationResponse , nil )
202
+ mockClientUtil .EXPECT ().MakeRawBackplaneAPIClientWithAccessToken ("https://uri2.example.com/" , testToken ).Return (mockClient , nil )
203
+ mockClient .EXPECT ().DeleteRemediation (context .TODO (), trueClusterID , & BackplaneApi.DeleteRemediationParams {Remediation : & testRemediationName }).Return (fakeResp , nil )
227
204
228
205
err := runDeleteRemediation ([]string {testRemediationName }, testClusterID , "https://uri2.example.com/" )
229
206
@@ -247,7 +224,7 @@ var _ = Describe("New Remediation command", func() {
247
224
mockOcmInterface .EXPECT ().GetOCMAccessToken ().Return (& testToken , nil )
248
225
mockOcmInterface .EXPECT ().IsClusterHibernating (gomock .Eq (trueClusterID )).Return (false , nil ).AnyTimes ()
249
226
250
- mockClientUtil .EXPECT ().MakeBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (nil , errors .New ("err" ))
227
+ mockClientUtil .EXPECT ().MakeRawBackplaneAPIClientWithAccessToken (backplaneAPIURI , testToken ).Return (nil , errors .New ("err" ))
251
228
252
229
err := runDeleteRemediation ([]string {testRemediationName }, testClusterID , backplaneAPIURI )
253
230
0 commit comments