Telegram bot for downloading media from any site using yt-dlp. Supports audio/video/both, quality selection, language picker, container format selection, playlist pagination, progress updates, per-user quotas, user preferences, download history, cancel at any step, polling and webhook modes, proxy support, and SQLite persistence.
27 lines
832 B
Go
27 lines
832 B
Go
package domain
|
|
|
|
import "testing"
|
|
|
|
func TestValidateURL(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
want string
|
|
ok bool
|
|
}{
|
|
{"https://www.youtube.com/watch?v=123", "https://www.youtube.com/watch?v=123", true},
|
|
{"http://example.com/video", "http://example.com/video", true},
|
|
{"https://vimeo.com/123456", "https://vimeo.com/123456", true},
|
|
{"https://www.pornhub.com/view_video.php?viewkey=123", "https://www.pornhub.com/view_video.php?viewkey=123", true},
|
|
{"", "", false},
|
|
{"not a url", "", false},
|
|
{"ftp://example.com", "", false},
|
|
{" https://example.com ", "https://example.com", true},
|
|
}
|
|
for _, tt := range tests {
|
|
got, ok := ValidateURL(tt.input)
|
|
if ok != tt.ok || (ok && got != tt.want) {
|
|
t.Errorf("ValidateURL(%q) = (%q, %v), want (%q, %v)", tt.input, got, ok, tt.want, tt.ok)
|
|
}
|
|
}
|
|
}
|