@@ -167,9 +167,8 @@ func TestWorkspaceHandler(t *testing.T) {
167
167
168
168
// Set request body
169
169
requestPayload := request.UpdateWorkspaceRequest {
170
- ID : 1 ,
171
- Name : wsNameUpdated ,
172
- BackendID : 1 ,
170
+ ID : 1 ,
171
+ Name : wsNameUpdated ,
173
172
}
174
173
reqBody , err := json .Marshal (requestPayload )
175
174
assert .NoError (t , err )
@@ -212,10 +211,16 @@ func TestWorkspaceHandler(t *testing.T) {
212
211
req = req .WithContext (context .WithValue (req .Context (), chi .RouteCtxKey , rctx ))
213
212
214
213
// Mock the Delete method of the workspace repository
214
+ sqlMock .ExpectQuery ("SELECT" ).
215
+ WillReturnRows (sqlmock .NewRows ([]string {"id" , "name" , "Backend__id" }).
216
+ AddRow (1 , "test-ws" , 1 ))
217
+ sqlMock .ExpectQuery ("SELECT" ).
218
+ WillReturnRows (sqlmock .NewRows ([]string {"id" , "backend_config" }).
219
+ AddRow (1 , "{\" type\" :\" local\" }" ))
215
220
sqlMock .ExpectBegin ()
216
221
sqlMock .ExpectQuery ("SELECT" ).
217
- WillReturnRows (sqlmock .NewRows ([]string {"id" }).
218
- AddRow (1 ))
222
+ WillReturnRows (sqlmock .NewRows ([]string {"id" , "name" , "Backend__id" }).
223
+ AddRow (1 , "test-ws" , 1 ))
219
224
sqlMock .ExpectExec ("DELETE" ).WillReturnResult (sqlmock .NewResult (1 , 0 ))
220
225
sqlMock .ExpectCommit ()
221
226
@@ -246,7 +251,6 @@ func TestWorkspaceHandler(t *testing.T) {
246
251
rctx .URLParams .Add ("workspaceID" , "1" )
247
252
req = req .WithContext (context .WithValue (req .Context (), chi .RouteCtxKey , rctx ))
248
253
249
- sqlMock .ExpectBegin ()
250
254
sqlMock .ExpectQuery ("SELECT" ).
251
255
WillReturnRows (sqlmock .NewRows ([]string {"id" }))
252
256
@@ -280,9 +284,8 @@ func TestWorkspaceHandler(t *testing.T) {
280
284
// Set request body
281
285
requestPayload := request.UpdateWorkspaceRequest {
282
286
// Set your request payload fields here
283
- ID : 1 ,
284
- Name : "test-ws-updated" ,
285
- BackendID : 1 ,
287
+ ID : 1 ,
288
+ Name : "test-ws-updated" ,
286
289
}
287
290
reqBody , err := json .Marshal (requestPayload )
288
291
assert .NoError (t , err )
@@ -380,3 +383,7 @@ func (m *mockStorage) GetCurrent() (string, error) {
380
383
func (m * mockStorage ) SetCurrent (name string ) error {
381
384
return nil
382
385
}
386
+
387
+ func (m * mockStorage ) RenameWorkspace (oldName , newName string ) error {
388
+ return nil
389
+ }
0 commit comments