-
Notifications
You must be signed in to change notification settings - Fork 2
/
metadata_test.go
50 lines (43 loc) · 890 Bytes
/
metadata_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
package main
import "testing"
//ArticleContent is defined in content_test.go
//This tests the GetMetadata function and Metadata
//struct. If this test passes and the content_test.go
//tests don't the error is probably in content.go or
//there is a broken test
func TestGetMetadataArticle(t *testing.T) {
m, _ := GetMetadata([]byte(ArticleContent))
if m.Title != "Test Article" {
t.Fail()
}
if m.Author != "Coconut Test" {
t.Fail()
}
if m.Date != "Jan 5 2015 13:50" {
t.Fail()
}
if m.Image != "" {
t.Fail()
}
if m.Tags[0] != "article" || m.Tags[1] != "test" || m.Tags[2] != "post" {
t.Fail()
}
}
func TestGetMetadataPage(t *testing.T) {
m, _ := GetMetadata([]byte(PageContent))
if m.Title != "Test Page" {
t.Fail()
}
if m.Author != "" {
t.Fail()
}
if m.Date != "" {
t.Fail()
}
if m.Image != "" {
t.Fail()
}
if len(m.Tags) > 0 {
t.Fail()
}
}