Files
NaviMigrate/internal/spotify/playlist_url_test.go

25 lines
613 B
Go

package spotify
import "testing"
func TestParsePlaylistID(t *testing.T) {
tests := []struct {
in string
want string
}{
{"spotify:playlist:16DZpOTLqZvdbqxEavLmWk", "16DZpOTLqZvdbqxEavLmWk"},
{"https://open.spotify.com/playlist/16DZpOTLqZvdbqxEavLmWk?si=abc", "16DZpOTLqZvdbqxEavLmWk"},
{"16DZpOTLqZvdbqxEavLmWk", "16DZpOTLqZvdbqxEavLmWk"},
}
for _, tt := range tests {
got, err := ParsePlaylistID(tt.in)
if err != nil {
t.Fatalf("ParsePlaylistID(%q) returned error: %v", tt.in, err)
}
if got != tt.want {
t.Fatalf("ParsePlaylistID(%q) = %q, want %q", tt.in, got, tt.want)
}
}
}