blob: 1df969b9ba591068bf6e967f65e0ef077838e0ab (
plain)
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
|
package linkedin
import (
"strings"
"testing"
)
func TestPreviewExtract(t *testing.T) {
var (
expectedTitle = "Baz"
expectedImageURL = "https://free.beer:666/bar/foo.jpg"
mockHTML = strings.NewReader(`
<!DOCTYPE html>
<html>
<head>
<title>Baz</title>
</head>
<body>
<img src="./foo.jpg" alt="Foo">
</body>
</html>
`)
)
title, imageURL, err := extract("https://free.beer:666/bar/", mockHTML)
if err != nil {
t.Error(err)
}
if title != expectedTitle {
t.Errorf("expected title '%s' but got '%s'", expectedTitle, title)
}
if imageURL != expectedImageURL {
t.Errorf("expected imageURL '%s' but got '%s'", expectedImageURL, imageURL)
}
}
|