Files
streamrip-go/internal/urlparse/parse_test.go
Joren b2688ce949 add CLI parity flags and expand provider support
This brings the Go CLI closer to upstream behavior with global flag handling and clearer resolve failures, while adding Tidal video downloads plus initial Deezer and SoundCloud no-account flows for broader end-to-end coverage.
2026-04-20 00:56:10 +02:00

119 lines
3.1 KiB
Go

package urlparse
import "testing"
func TestDeezerDynamicURL(t *testing.T) {
url := "https://dzr.page.link/SnV6hCyHihkmCCwUA"
result := Parse(url)
if result == nil {
t.Fatalf("expected parsed url")
}
if result.Source != "deezer" {
t.Fatalf("source = %q, want deezer", result.Source)
}
if result.Kind != KindDeezerDynamic {
t.Fatalf("kind = %q, want %q", result.Kind, KindDeezerDynamic)
}
}
func TestQobuzAlbumURL(t *testing.T) {
url := "https://www.qobuz.com/fr-fr/album/bizarre-ride-ii-the-pharcyde-the-pharcyde/0066991040005"
result := Parse(url)
if result == nil {
t.Fatalf("expected parsed url")
}
if result.Source != "qobuz" || result.MediaType != "album" || result.ID != "0066991040005" {
t.Fatalf("unexpected parse result: %+v", result)
}
}
func TestTidalTrackURL(t *testing.T) {
url := "https://tidal.com/browse/track/3083287"
result := Parse(url)
if result == nil {
t.Fatalf("expected parsed url")
}
if result.Source != "tidal" || result.MediaType != "track" || result.ID != "3083287" {
t.Fatalf("unexpected parse result: %+v", result)
}
}
func TestTidalVideoURL(t *testing.T) {
url := "https://tidal.com/browse/video/59727844"
result := Parse(url)
if result == nil {
t.Fatalf("expected parsed url")
}
if result.Source != "tidal" || result.MediaType != "video" || result.ID != "59727844" {
t.Fatalf("unexpected parse result: %+v", result)
}
}
func TestDeezerTrackURL(t *testing.T) {
url := "https://www.deezer.com/track/4195713"
result := Parse(url)
if result == nil {
t.Fatalf("expected parsed url")
}
if result.Source != "deezer" || result.MediaType != "track" || result.ID != "4195713" {
t.Fatalf("unexpected parse result: %+v", result)
}
}
func TestInvalidURL(t *testing.T) {
inputs := []string{
"https://example.com",
"not a url",
"https://spotify.com/track/123456",
"https://tidal.com/invalid/3083287",
}
for _, input := range inputs {
if result := Parse(input); result != nil {
t.Fatalf("expected nil for %q, got %+v", input, result)
}
}
}
func TestAlternateURLFormats(t *testing.T) {
inputs := []string{
"https://open.tidal.com/track/3083287",
"https://play.qobuz.com/album/0066991040005",
"https://listen.tidal.com/track/3083287",
}
for _, input := range inputs {
if result := Parse(input); result == nil {
t.Fatalf("expected parse for %q", input)
}
}
}
func TestURLWithLanguageCode(t *testing.T) {
inputs := []string{
"https://www.qobuz.com/us-en/album/name/id123456",
"https://www.qobuz.com/gb-en/album/name/id123456",
"https://www.deezer.com/en/track/4195713",
"https://www.deezer.com/fr/track/4195713",
}
for _, input := range inputs {
if result := Parse(input); result == nil {
t.Fatalf("expected parse for %q", input)
}
}
}
func TestSoundcloudURL(t *testing.T) {
inputs := []string{
"https://soundcloud.com/artist-name/track-name",
"https://soundcloud.com/artist-name/sets/playlist-name",
}
for _, input := range inputs {
result := Parse(input)
if result == nil {
t.Fatalf("expected parse for %q", input)
}
if result.Source != "soundcloud" || result.Kind != KindSoundcloud {
t.Fatalf("unexpected parse result: %+v", result)
}
}
}