-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo-platform-url_test.go
60 lines (50 loc) · 2.35 KB
/
video-platform-url_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package videoPlatformURL
import "testing"
func TestAnalyzeDomain(t *testing.T) {
facebookFullURL := "https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2FMTV%2Fvideos%2F10153999880236701%2F&show_text=0&width=560"
expected := "https://www.facebook.com/MTV/videos/10153999880236701/&show_text=0&width=560"
actual := analyzeDomain(facebookFullURL)
if actual != expected {
t.Errorf("Test failed, expected: '%s', got: '%s'", expected, actual)
}
}
func TestFindURL(t *testing.T) {
var expected string
var actual string
youtubeID := "T8GRwkZDCBU"
expected = "https://www.youtube.com/watch?v=T8GRwkZDCBU"
actual = FindURL(youtubeID, "youtube")
if actual != expected {
t.Errorf("Test failed, expected: '%s', got: '%s'", expected, actual)
}
dailymotionID := "x4qfa0s"
expected = "http://www.dailymotion.com/video/x4qfa0s"
actual = FindURL(dailymotionID, "dailymotion")
if actual != expected {
t.Errorf("Test failed, expected: '%s', got: '%s'", expected, actual)
}
digitekaID := "8mruqx"
expected = "https://www.ultimedia.com/deliver/generic/iframe/mdtk/01836272/src/8mruqx"
actual = FindURL(digitekaID, "digiteka")
if actual != expected {
t.Errorf("Test failed, expected: '%s', got: '%s'", expected, actual)
}
digitekaID2 := "http://ngs14c.digiteka.net/862acf558ea2bead6e6f2dbc40de50c5/c3BlZWQ9MTUwO3VzZXI9bmdzO2V4cGlyZT01OGNhYTJkZA,,/sdj1/d9/a4/d9a4565aefe466757adca25d96153bf7745c6ccb.mp4"
expected = "http://ngs14c.digiteka.net/862acf558ea2bead6e6f2dbc40de50c5/c3BlZWQ9MTUwO3VzZXI9bmdzO2V4cGlyZT01OGNhYTJkZA,,/sdj1/d9/a4/d9a4565aefe466757adca25d96153bf7745c6ccb.mp4"
actual = FindURL(digitekaID2, "digiteka")
if actual != expected {
t.Errorf("Test failed, expected: '%s', got: '%s'", expected, actual)
}
proxyURL := "http://www.20minutes.fr/insolite/1914323-20160828-harcele-trolls-zoo-cincinnati-decide-fermer-compte-twitter"
expected = "http://www.20minutes.fr/insolite/1914323-20160828-harcele-trolls-zoo-cincinnati-decide-fermer-compte-twitter"
actual = FindURL(proxyURL, "proxy")
if actual != expected {
t.Errorf("Test failed, expected: '%s', got: '%s'", expected, actual)
}
proxyShortURL := "http://www.20minutes.fr/1914323"
expected = "http://www.20minutes.fr/1914323"
actual = FindURL(proxyShortURL, "proxy")
if actual != expected {
t.Errorf("Test failed, expected: '%s', got: '%s'", expected, actual)
}
}