-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebprev_test.go
36 lines (30 loc) · 1.15 KB
/
webprev_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
package webprev
import (
"testing"
)
func TestPreview(t *testing.T) {
webPrev, err := Preview("https://basicbb.com")
if err != nil {
t.Errorf("Preview() err = %v; want nothing", err)
}
if webPrev.Generic.Title == "" {
t.Errorf("Preview() title = %v; want something", webPrev.Generic.Title)
}
//fmt.Println(webPrev.Generic.Title)
//fmt.Println(webPrev.Generic.Description)
//fmt.Println(webPrev.Generic.ImgURL)
}
func TestSupplementImgURL(t *testing.T) {
if got := supplementImgURL("", "bla"); got != "bla" {
t.Errorf("supplementImgURL('', 'bla') = %v; want true", got)
}
if got := supplementImgURL("https://some.domain", "http://other.domain"); got != "http://other.domain" {
t.Errorf("supplementImgURL('', 'bla') = %v; want http://other.domain", got)
}
if got := supplementImgURL("https://some.domain/", "img.jpeg"); got != "https://some.domain/img.jpeg" {
t.Errorf("supplementImgURL('', 'bla') = %v; want https://some.domain/img.jpeg", got)
}
if got := supplementImgURL("https://some.domain", "/img.jpeg"); got != "https://some.domain/img.jpeg" {
t.Errorf("supplementImgURL('', 'bla') = %v; want https://some.domain/img.jpeg", got)
}
}