tstor/pkg/ytdlp/playlist_test.go

28 lines
687 B
Go
Raw Permalink Normal View History

2024-05-13 16:56:20 +00:00
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))
}