-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookmark_test.go
62 lines (49 loc) · 1.37 KB
/
bookmark_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
package main
import (
"testing"
"github.com/google/go-cmp/cmp"
)
var (
expectedURL = BookmarkURLs{
"https://golang.org": []Tag{"go", "google", "docs", "code"},
"https://github.com": []Tag{"code", "github", "favorite"},
}
expectedTag = BookmarkTags{
"go": []URL{"https://golang.org"},
"google": []URL{"https://golang.org"},
"docs": []URL{"https://golang.org"},
"code": []URL{"https://golang.org", "https://github.com"},
"github": []URL{"https://github.com"},
"favorite": []URL{"https://github.com"},
}
)
func TestURLSaveJSONStruct(t *testing.T) {
expectedURL.save("test/saveURL.json")
var got BookmarkURLs
got.load("test/saveURL.json")
if !cmp.Equal(expectedURL, got) {
t.Errorf("Expected: \n%v\nGot: \n%v\n", expectedURL, got)
}
}
func TestURLLoadJSON(t *testing.T) {
var got BookmarkURLs
got.load("test/loadURL.json")
if !cmp.Equal(expectedURL, got) {
t.Errorf("Expected: \n%v\nGot: \n%v\n", expectedURL, got)
}
}
func TestTagSaveJSONStruct(t *testing.T) {
expectedTag.save("test/saveTag.json")
var got BookmarkTags
got.load("test/saveTag.json")
if !cmp.Equal(expectedTag, got) {
t.Errorf("Expected: \n%v\nGot: \n%v\n", expectedTag, got)
}
}
func TestTagLoadJSON(t *testing.T) {
var got BookmarkTags
got.load("test/loadTag.json")
if !cmp.Equal(expectedTag, got) {
t.Errorf("Expected: \n%v\nGot: \n%v\n", expectedTag, got)
}
}