From e2ad05cf0d09ecbf6bbfd02b2359a4afdb3fb6d4 Mon Sep 17 00:00:00 2001 From: Niko Abeler Date: Mon, 5 Dec 2022 18:46:00 +0100 Subject: [PATCH] Fixes #36 --- post.go | 2 ++ post_test.go | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/post.go b/post.go index 90eb5cf..a4d4ab0 100644 --- a/post.go +++ b/post.go @@ -181,6 +181,8 @@ func (post *Post) RenderedContent() string { // trim yaml block // TODO this can be done nicer trimmedData := bytes.TrimSpace(data) + // ensure that data ends with a newline + trimmedData = append(trimmedData, []byte("\n")...) // check first line is --- if string(trimmedData[0:4]) == "---\n" { trimmedData = trimmedData[4:] diff --git a/post_test.go b/post_test.go index 67b30a9..898bf72 100644 --- a/post_test.go +++ b/post_test.go @@ -465,6 +465,15 @@ func TestComplexParallelWebmentions(t *testing.T) { assertions.AssertLen(t, outs, 20) } +func TestPostWithoutContent(t *testing.T) { + repo := getTestRepo(owl.RepoConfig{}) + user, _ := repo.CreateUser("testuser") + post, _ := user.CreateNewPostFull(owl.PostMeta{}, "") + + result := post.RenderedContent() + assertions.AssertEqual(t, result, "") +} + // func TestComplexParallelSimulatedProcessesWebmentions(t *testing.T) { // repoName := testRepoName() // repo, _ := owl.CreateRepository(repoName, owl.RepoConfig{})