Skip to content

Commit 9672d83

Browse files
committed
Fix TestGetPlaylistChannel panic on empty response
Use require.NotEmpty instead of assert.NotEmpty for length-dependent slice index access to prevent index-out-of-range panic when Deezer returns empty sections.
1 parent d30db2b commit 9672d83

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎api/api_test.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/d-fi/GoFi/request"
1010
"github.com/d-fi/GoFi/types"
1111
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
1213
)
1314

1415
const (
@@ -164,9 +165,9 @@ func TestGetShowInfo(t *testing.T) {
164165

165166
func TestGetPlaylistChannel(t *testing.T) {
166167
response, err := GetPlaylistChannel("channels/dance")
167-
assert.NoError(t, err)
168+
require.NoError(t, err)
168169
assert.NotEmpty(t, response.Title)
169-
assert.NotEmpty(t, response.Sections)
170-
assert.NotEmpty(t, response.Sections[0].Items)
170+
require.NotEmpty(t, response.Sections)
171+
require.NotEmpty(t, response.Sections[0].Items)
171172
assert.IsType(t, &types.PlaylistChannelPlaylistData{}, response.Sections[0].Items[0].Data)
172173
}

0 commit comments

Comments
 (0)