-
Notifications
You must be signed in to change notification settings - Fork 0
/
ebook_test.go
61 lines (47 loc) · 1.48 KB
/
ebook_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
package pgrdf_test
import (
"testing"
"github.com/mrcook/pgrdf"
)
func TestEbook_AddSubject(t *testing.T) {
ebook := pgrdf.Ebook{}
ebook.AddSubject("Fiction", "http://purl.org/dc/terms/LCSH")
if len(ebook.Subjects) != 1 {
t.Fatalf("expected 1 subject, got: %d", len(ebook.Subjects))
}
subject := ebook.Subjects[0]
if subject.Heading != "Fiction" {
t.Errorf("unexpected heading: '%s'", subject.Heading)
}
if subject.Schema != "http://purl.org/dc/terms/LCSH" {
t.Errorf("unexpected schema: '%s'", subject.Schema)
}
}
func TestEbook_AddBookshelf(t *testing.T) {
ebook := pgrdf.Ebook{}
ebook.AddBookshelf("My Bookshelf", "2009/pgterms/Bookshelf")
if len(ebook.Bookshelves) != 1 {
t.Fatalf("expected 1 bookshelf, got: %d", len(ebook.Bookshelves))
}
shelf := ebook.Bookshelves[0]
if shelf.Name != "My Bookshelf" {
t.Errorf("unexpected name: '%s'", shelf.Name)
}
if shelf.Resource != "2009/pgterms/Bookshelf" {
t.Errorf("unexpected resource: '%s'", shelf.Resource)
}
}
func TestEbook_AddAuthorLink(t *testing.T) {
ebook := pgrdf.Ebook{}
ebook.AddAuthorLink("en.wikipedia", "https://en.wikipedia.org/wiki/Charles_Dickens")
if len(ebook.AuthorLinks) != 1 {
t.Fatalf("expected 1 link, got: %d", len(ebook.AuthorLinks))
}
link := ebook.AuthorLinks[0]
if link.Description != "en.wikipedia" {
t.Errorf("unexpected description: '%s'", link.Description)
}
if link.URL != "https://en.wikipedia.org/wiki/Charles_Dickens" {
t.Errorf("unexpected url: '%s'", link.URL)
}
}