Skip to content

Commit 0bd5a63

Browse files
committed
Merge branch 'feature/delete-songs' of https://github.com/DutchJavaDev/MyMusicBox into feature/delete-songs
2 parents 5b82bcd + 5eb4f58 commit 0bd5a63

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

MyMusicBoxApi/http/playlist_test.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ func TestDeletePlaylistPlaylistId(t *testing.T) {
265265

266266
recorder := httptest.NewRecorder()
267267

268-
// Unable to parse to int, will throw error
269-
_route := "/playlist/1"
268+
_route := "/playlist/2"
270269

271270
req, _ := http.NewRequest("DELETE", _route, nil)
272271

@@ -276,3 +275,33 @@ func TestDeletePlaylistPlaylistId(t *testing.T) {
276275
// Assert
277276
assert.Equal(t, http.StatusOK, recorder.Code)
278277
}
278+
279+
func TestDeletePlaylistPlaylistIdDefaultPlaylist(t *testing.T) {
280+
// Arrange
281+
route := "/playlist/:playlistId"
282+
router := SetupTestRouter()
283+
284+
mockTable := &mockPlaylistTable{
285+
deletePlaylist: func(playlistId int) (error error) {
286+
return nil
287+
},
288+
}
289+
290+
playlistHandler := PlaylistHandler{
291+
PlaylistTable: mockTable,
292+
}
293+
294+
router.DELETE(route, playlistHandler.DeletePlaylist)
295+
296+
recorder := httptest.NewRecorder()
297+
298+
_route := "/playlist/1"
299+
300+
req, _ := http.NewRequest("DELETE", _route, nil)
301+
302+
// Act
303+
router.ServeHTTP(recorder, req)
304+
305+
// Assert
306+
assert.Equal(t, http.StatusInternalServerError, recorder.Code)
307+
}

MyMusicBoxApi/models/http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func ErrorResponse(data any) ApiResponseModel {
2525
Message: "An error occurred",
2626
}
2727
}
28+
2829
func OkResponse(data any, message string) ApiResponseModel {
2930
return ApiResponseModel{
3031
Data: data,

0 commit comments

Comments
 (0)