added musify test

This commit is contained in:
Hazel Noack 2025-10-06 15:21:55 +02:00
parent c43a7cb154
commit b1cc6506d0
2 changed files with 31 additions and 0 deletions

View File

@ -12,6 +12,7 @@ type SourceType struct {
var SourceTypes = []SourceType{
{Name: "Youtube", Regex: *regexp.MustCompile(`(?i)\b(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})\b`)},
{Name: "Musify", Regex: *regexp.MustCompile(`(?i)https?://musify\.club/(artist|track|release)/[a-z\-0-9]+`)},
}
func GetSourceType(name string) *SourceType {

View File

@ -38,3 +38,33 @@ func TestYouTube(t *testing.T) {
}
}
}
func TestMusify(t *testing.T) {
validUrls := []string{
"https://musify.club/artist/plohoyparen-645023",
"https://musify.club/track/plohoyparen-obgon-dve-sploshnie-poh-voobshe-9769231",
"https://musify.club/release/plohoyparen-hello-my-name-2018-1029885",
"https://musify.clUb/Release/plohoyParen-hello-my-name-2018-1029885",
}
invalidUrls := []string{
"https://musify.club/",
"https://musify.club/not-data-type",
"https://m.youtube.com/watch?v=dQw4w9WgXcQ",
}
st := GetSourceType("Musify")
for _, u := range validUrls {
_, err := st.NewSource(u)
if err != nil {
t.Errorf(`%q is a valid musify url`, u)
}
}
for _, u := range invalidUrls {
_, err := st.NewSource(u)
if err == nil {
t.Errorf(`%q is an invalid musify url`, u)
}
}
}