2019-03-27 14:18:52 +00:00
|
|
|
package blog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLoadPosts(t *testing.T) {
|
2019-05-22 01:47:09 +00:00
|
|
|
posts, err := LoadPosts("../../blog", "blog")
|
2019-03-27 14:18:52 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2019-05-22 01:47:09 +00:00
|
|
|
|
|
|
|
for _, post := range posts {
|
|
|
|
t.Run(post.Link, post.test)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLoadTalks(t *testing.T) {
|
|
|
|
talks, err := LoadPosts("../../talks", "talks")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, talk := range talks {
|
|
|
|
t.Run(talk.Link, talk.test)
|
|
|
|
if talk.SlidesLink == "" {
|
|
|
|
t.Errorf("talk %s (%s) doesn't have a slides link", talk.Title, talk.DateString)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-01 21:48:19 +00:00
|
|
|
func TestLoadGallery(t *testing.T) {
|
|
|
|
gallery, err := LoadPosts("../../gallery", "gallery")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, art := range gallery {
|
|
|
|
t.Run(art.Link, art.test)
|
|
|
|
if art.ImageURL == "" {
|
|
|
|
t.Errorf("art %s (%s) doesn't have an image link", art.Title, art.DateString)
|
|
|
|
}
|
|
|
|
if art.ThumbURL == "" {
|
|
|
|
t.Errorf("art %s (%s) doesn't have a thumbnail link", art.Title, art.DateString)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-22 01:47:09 +00:00
|
|
|
func (p Post) test(t *testing.T) {
|
|
|
|
if p.Title == "" {
|
|
|
|
t.Error("no post title")
|
|
|
|
}
|
|
|
|
|
|
|
|
if p.DateString == "" {
|
|
|
|
t.Error("no date")
|
|
|
|
}
|
|
|
|
|
|
|
|
if p.Link == "" {
|
|
|
|
t.Error("no link")
|
|
|
|
}
|
|
|
|
|
|
|
|
if p.Body == "" {
|
|
|
|
t.Error("no body")
|
|
|
|
}
|
2019-03-27 14:18:52 +00:00
|
|
|
}
|