Make response type an/single/playlist

Make it possible to assert what response to get
This commit is contained in:
Mattias Wadman
2019-11-01 00:01:13 +01:00
parent 941a4092e2
commit 5b6ef4f1f2
3 changed files with 54 additions and 21 deletions

View File

@ -157,7 +157,7 @@ func TestPlaylist(t *testing.T) {
defer leakChecks(t)()
ydlResult, ydlResultErr := New(context.Background(), playlistRawURL, Options{
YesPlaylist: true,
Type: TypePlaylist,
DownloadThumbnail: false,
})
@ -186,7 +186,7 @@ func TestPlaylistWithPrivateVideo(t *testing.T) {
playlistRawURL := "https://www.youtube.com/playlist?list=PLX0g748fkegS54oiDN4AXKl7BR7mLIydP"
ydlResult, ydlResultErr := New(context.Background(), playlistRawURL, Options{
YesPlaylist: true,
Type: TypePlaylist,
DownloadThumbnail: false,
})
@ -201,20 +201,6 @@ func TestPlaylistWithPrivateVideo(t *testing.T) {
}
}
func TestPlaylistBadURL(t *testing.T) {
defer leakChecks(t)()
// using a non-playlist url
_, ydlResultErr := New(context.Background(), testVideoRawURL, Options{
YesPlaylist: true,
DownloadThumbnail: false,
})
if ydlResultErr == nil {
t.Error("expected error")
}
}
func TestSubtitles(t *testing.T) {
defer leakChecks(t)()
@ -246,3 +232,23 @@ func TestSubtitles(t *testing.T) {
}
}
}
func TestErrorNotAPlaylist(t *testing.T) {
_, ydlResultErr := New(context.Background(), testVideoRawURL, Options{
Type: TypePlaylist,
DownloadThumbnail: false,
})
if ydlResultErr.Error() != "not a playlist" {
t.Errorf("expected is playlist error")
}
}
func TestErrorNotASingle(t *testing.T) {
_, ydlResultErr := New(context.Background(), playlistRawURL, Options{
Type: TypeSingle,
DownloadThumbnail: false,
})
if ydlResultErr.Error() != "not a single" {
t.Errorf("expected is playlist error")
}
}