diff --git a/blogposts/blogposts.go b/blogposts/blogposts.go new file mode 100644 index 0000000..2ca1c49 --- /dev/null +++ b/blogposts/blogposts.go @@ -0,0 +1,12 @@ +package blogposts + +import "io/fs" + +type Post struct { + Title, Description, Body string + Tags []string +} + +func NewPostsFromFS(fs fs.FS) []Post { + return []Post{{}, {}} +} diff --git a/blogposts/blogposts_test.go b/blogposts/blogposts_test.go new file mode 100644 index 0000000..96f3b9f --- /dev/null +++ b/blogposts/blogposts_test.go @@ -0,0 +1,20 @@ +package blogposts + +import ( + "testing" + "testing/fstest" +) + +// NOTE: This should be a black box test outside blogposts package. + +func TestNewBlogPosts(t *testing.T) { + fs := fstest.MapFS{ + "hello world.md": {Data: []byte("hi")}, + "hello-world2.md": {Data: []byte("hola")}, + } + + posts := NewPostsFromFS(fs) + if len(posts) != len(fs) { + t.Errorf("got %d posts, wanted %d posts", len(posts), len(fs)) + } +} diff --git a/blogposts/hello_world.md b/blogposts/hello_world.md new file mode 100644 index 0000000..cab1f16 --- /dev/null +++ b/blogposts/hello_world.md @@ -0,0 +1,7 @@ +Title: Hello, TDD world! +Description: First post on our wonderful blog +Tags: tdd, go +--- +Hello world! + +The body of posts starts after the `---`