added musify test
This commit is contained in:
parent
c43a7cb154
commit
b1cc6506d0
@ -12,6 +12,7 @@ type SourceType struct {
|
|||||||
|
|
||||||
var SourceTypes = []SourceType{
|
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: "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 {
|
func GetSourceType(name string) *SourceType {
|
||||||
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user