package validation import "testing" func TestIsUrl(t *testing.T) { is, _ := IsUrl("definitely not a url") if is { t.Error("Non-url text detected as URL") } is, _ = IsUrl("https://example.com") if !is { t.Error("URL not detected as URL") } } func TestIsMusicUrlErrors(t *testing.T) { // Not a URL is, err := IsMusicUrl("not a url") if is { t.Error("Non-URL was detected as url") } if err != ErrNotAUrl { t.Error("Incorrect error returned for Non-url link") } // Incorrect protocol is, err = IsMusicUrl("ssh://youtube.com") if is { t.Error("Incorrect protocol was not caught") } if err != ErrIncorrectProtocol { t.Error("Incorrect error returned for incorrect protocol") } // Unsupported service is, err = IsMusicUrl("https://www.deezer.com/") if is { t.Error("Unsupported service was not caught") } if err != ErrServiceUnsupported { t.Error("Unsupported service did not return the correct error") } }