tstor/pkg/ytdlp/playlist_test.go
2024-05-13 19:56:20 +03:00

27 lines
687 B
Go

package ytdlp_test
import (
"context"
"errors"
"testing"
"git.kmsign.ru/royalcat/tstor/pkg/ytdlp"
"github.com/stretchr/testify/require"
)
func TestPlaylist(t *testing.T) {
require := require.New(t)
ctx := context.Background()
if deadline, ok := t.Deadline(); ok {
var cancel context.CancelFunc
ctx, cancel = context.WithDeadlineCause(ctx, deadline, errors.New("test deadline done"))
defer cancel()
}
client, err := ytdlp.New()
require.NoError(err)
entries, err := client.Playlist(ctx, "https://www.youtube.com/playlist?list=PLUay9m6GhoyCXdloEa-VYtnVeshaKl4AW")
require.NoError(err)
require.NotEmpty(entries)
require.Len(entries, int(entries[0].PlaylistCount))
}