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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|