Skip to content

Commit cf1ffbd

Browse files
committed
fix test
1 parent 2ef24c6 commit cf1ffbd

1 file changed

Lines changed: 31 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+
}

0 commit comments

Comments
 (0)