-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookmarks_test.go
67 lines (60 loc) · 1.48 KB
/
bookmarks_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
61
62
63
64
65
66
67
package bookmarks_test
import (
"os"
"testing"
"github.com/go-test/deep"
bookmarks "github.com/suhodolskiy/netscape-bookmarks"
"gotest.tools/v3/assert"
)
var want = bookmarks.Children{
bookmarks.Folder{
Name: "Bookmarks Bar",
AddDate: "1611420722",
LastModified: "1650397116",
Children: bookmarks.Children{
bookmarks.Bookmark{
Name: "Google",
AddDate: "1650397103",
Href: "https://www.google.com/",
Attributes: []bookmarks.Attribute{},
},
bookmarks.Folder{
Name: "Github",
AddDate: "1650397124",
LastModified: "1650397155",
Children: bookmarks.Children{
bookmarks.Bookmark{
Name: "The React documentation website",
AddDate: "1650397152",
Href: "https://github.com/reactjs/reactjs.org",
Attributes: []bookmarks.Attribute{},
},
},
Attributes: []bookmarks.Attribute{},
},
},
Attributes: []bookmarks.Attribute{},
},
bookmarks.Bookmark{
Name: "Golang Net html",
AddDate: "1650055527",
Href: "https://zetcode.com/golang/net-html/",
Attributes: []bookmarks.Attribute{
{
Key: "custom_attr",
Value: "TRUE",
},
},
},
}
func TestBookmarks(t *testing.T) {
file, err := os.OpenFile("./example.html", os.O_RDONLY, 0644)
assert.NilError(t, err)
defer file.Close()
result, err := bookmarks.Parse(file)
assert.NilError(t, err)
diff := deep.Equal(result, want)
if diff != nil {
t.Errorf("compare failed: %v", diff)
}
}