remove old new post function

This commit is contained in:
Niko Abeler 2022-12-05 20:47:52 +01:00
parent 1fefa2a140
commit cad4897583
18 changed files with 127 additions and 129 deletions

View File

@ -40,7 +40,7 @@ var newPostCmd = &cobra.Command{
return
}
post, err := user.CreateNewPost(postTitle, true)
post, err := user.CreateNewPost(owl.PostMeta{Type: "article", Title: postTitle, Draft: true}, "")
if err != nil {
println("Error creating post: ", err.Error())
} else {

View File

@ -13,7 +13,7 @@ import (
func TestRedirectOnAliases(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "post-1"}, "")
content := "---\n"
content += "title: Test\n"
@ -39,7 +39,7 @@ func TestRedirectOnAliases(t *testing.T) {
func TestNoRedirectOnNonExistingAliases(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "post-1"}, "")
content := "---\n"
content += "title: Test\n"
@ -64,8 +64,8 @@ func TestNoRedirectOnNonExistingAliases(t *testing.T) {
func TestNoRedirectIfValidPostUrl(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post2, _ := user.CreateNewPost("post-2", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "post-1"}, "")
post2, _ := user.CreateNewPost(owl.PostMeta{Title: "post-2"}, "")
content := "---\n"
content += "title: Test\n"
@ -89,7 +89,7 @@ func TestNoRedirectIfValidPostUrl(t *testing.T) {
func TestRedirectIfInvalidPostUrl(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "post-1"}, "")
content := "---\n"
content += "title: Test\n"
@ -113,7 +113,7 @@ func TestRedirectIfInvalidPostUrl(t *testing.T) {
func TestRedirectIfInvalidUserUrl(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "post-1"}, "")
content := "---\n"
content += "title: Test\n"
@ -137,7 +137,7 @@ func TestRedirectIfInvalidUserUrl(t *testing.T) {
func TestRedirectIfInvalidMediaUrl(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "post-1"}, "")
content := "---\n"
content += "title: Test\n"
@ -161,7 +161,7 @@ func TestRedirectIfInvalidMediaUrl(t *testing.T) {
func TestDeepAliasInSingleUserMode(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{SingleUser: "test-1"})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "post-1"}, "")
content := "---\n"
content += "title: Create tileable textures with GIMP\n"

View File

@ -245,7 +245,7 @@ func userEditorPostHandler(repo *owl.Repository) func(http.ResponseWriter, *http
// TODO: scrape bookmark_url for title and description
// create post
post, err := user.CreateNewPostFull(owl.PostMeta{
post, err := user.CreateNewPost(owl.PostMeta{
Type: post_type,
Title: title,
Description: description,

View File

@ -1,6 +1,7 @@
package web_test
import (
"h4kor/owl-blogs"
main "h4kor/owl-blogs/cmd/owl/web"
"h4kor/owl-blogs/test/assertions"
"h4kor/owl-blogs/test/mocks"
@ -212,7 +213,7 @@ func TestEditorSendsWebmentions(t *testing.T) {
repo.Parser = &mocks.MockHtmlParser{}
user.ResetPassword("testpassword")
mentioned_post, _ := user.CreateNewPost("test", false)
mentioned_post, _ := user.CreateNewPost(owl.PostMeta{Title: "test"}, "")
sessionId := user.CreateNewSession()

View File

@ -144,7 +144,7 @@ func userWebmentionHandler(repo *owl.Repository) func(http.ResponseWriter, *http
return
}
tryAlias := func(target string) *owl.Post {
tryAlias := func(target string) owl.IPost {
parsedTarget, _ := url.Parse(target)
aliases, _ := repo.PostAliases()
fmt.Printf("aliases %v", aliases)
@ -155,7 +155,7 @@ func userWebmentionHandler(repo *owl.Repository) func(http.ResponseWriter, *http
return nil
}
var aliasPost *owl.Post
var aliasPost owl.IPost
parts := strings.Split(target[0], "/")
if len(parts) < 2 {
aliasPost = tryAlias(target[0])
@ -333,7 +333,7 @@ func userMicropubHandler(repo *owl.Repository) func(http.ResponseWriter, *http.R
}
// create post
post, err := user.CreateNewPostFull(
post, err := user.CreateNewPost(
owl.PostMeta{
Title: name,
Reply: owl.ReplyData{

View File

@ -54,7 +54,7 @@ func TestMultiUserRepoIndexHandler(t *testing.T) {
func TestMultiUserUserIndexHandler(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
user.CreateNewPost("post-1", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
// Create Request and Response
req, err := http.NewRequest("GET", user.UrlPath(), nil)
@ -72,7 +72,7 @@ func TestMultiUserUserIndexHandler(t *testing.T) {
func TestMultiUserPostHandler(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
// Create Request and Response
req, err := http.NewRequest("GET", post.UrlPath(), nil)
@ -87,7 +87,7 @@ func TestMultiUserPostHandler(t *testing.T) {
func TestMultiUserPostMediaHandler(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
// Create test media file
path := path.Join(post.MediaDir(), "data.txt")

View File

@ -13,7 +13,7 @@ import (
func TestPostHandlerReturns404OnDrafts(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "post-1"}, "")
content := "---\n"
content += "title: test\n"

View File

@ -12,7 +12,7 @@ import (
func TestMultiUserUserRssIndexHandler(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
user.CreateNewPost("post-1", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
// Create Request and Response
req, err := http.NewRequest("GET", user.UrlPath()+"index.xml", nil)

View File

@ -19,7 +19,7 @@ func getSingleUserTestRepo() (owl.Repository, owl.User) {
func TestSingleUserUserIndexHandler(t *testing.T) {
repo, user := getSingleUserTestRepo()
user.CreateNewPost("post-1", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
// Create Request and Response
req, err := http.NewRequest("GET", user.UrlPath(), nil)
@ -36,7 +36,7 @@ func TestSingleUserUserIndexHandler(t *testing.T) {
func TestSingleUserPostHandler(t *testing.T) {
repo, user := getSingleUserTestRepo()
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
// Create Request and Response
req, err := http.NewRequest("GET", post.UrlPath(), nil)
@ -50,7 +50,7 @@ func TestSingleUserPostHandler(t *testing.T) {
func TestSingleUserPostMediaHandler(t *testing.T) {
repo, user := getSingleUserTestRepo()
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
// Create test media file
path := path.Join(post.MediaDir(), "data.txt")
@ -72,7 +72,7 @@ func TestSingleUserPostMediaHandler(t *testing.T) {
func TestHasNoDraftsInList(t *testing.T) {
repo, user := getSingleUserTestRepo()
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
content := ""
content += "---\n"
content += "title: Articles September 2019\n"
@ -102,11 +102,11 @@ func TestHasNoDraftsInList(t *testing.T) {
func TestSingleUserUserPostListHandler(t *testing.T) {
repo, user := getSingleUserTestRepo()
user.CreateNewPostFull(owl.PostMeta{
user.CreateNewPost(owl.PostMeta{
Title: "post-1",
Type: "article",
}, "hi")
user.CreateNewPostFull(owl.PostMeta{
user.CreateNewPost(owl.PostMeta{
Title: "post-2",
Type: "note",
}, "hi")

View File

@ -38,7 +38,7 @@ func setupWebmentionTest(repo owl.Repository, user owl.User, target string, sour
func TestWebmentionHandleAccepts(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
target := post.FullUrl()
source := "https://example.com"
@ -54,7 +54,7 @@ func TestWebmentionWrittenToPost(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
target := post.FullUrl()
source := "https://example.com"
@ -77,7 +77,7 @@ func TestWebmentionSourceValidation(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
target := post.FullUrl()
source := "ftp://example.com"
@ -92,7 +92,7 @@ func TestWebmentionTargetValidation(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
target := "ftp://example.com"
source := post.FullUrl()
@ -109,7 +109,7 @@ func TestWebmentionSameTargetAndSource(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
target := post.FullUrl()
source := post.FullUrl()
@ -126,7 +126,7 @@ func TestWebmentionSameTargetAndSource(t *testing.T) {
func TestValidationOfTarget(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
target := post.FullUrl()
target = target[:len(target)-1] + "invalid"
@ -141,7 +141,7 @@ func TestValidationOfTarget(t *testing.T) {
func TestAcceptWebmentionForAlias(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("test-1")
post, _ := user.CreateNewPost("post-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "post-1"}, "")
content := "---\n"
content += "title: Test\n"

View File

@ -46,7 +46,7 @@ var webmentionCmd = &cobra.Command{
}
}
processPost := func(user owl.User, post *owl.Post) error {
processPost := func(user owl.User, post owl.IPost) error {
println("Webmentions for post: ", post.Title())
err := post.ScanForLinks()

View File

@ -260,6 +260,8 @@ func (post *Post) LoadMeta() error {
// get yaml metadata block
meta := PostMeta{}
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:]

View File

@ -14,49 +14,49 @@ import (
func TestCanGetPostTitle(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result := post.Title()
assertions.AssertEqual(t, result, "testpost")
}
func TestMediaDir(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result := post.MediaDir()
assertions.AssertEqual(t, result, path.Join(post.Dir(), "media"))
}
func TestPostUrlPath(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
expected := "/user/" + user.Name() + "/posts/" + post.Id() + "/"
assertions.AssertEqual(t, post.UrlPath(), expected)
}
func TestPostFullUrl(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
expected := "http://localhost:8080/user/" + user.Name() + "/posts/" + post.Id() + "/"
assertions.AssertEqual(t, post.FullUrl(), expected)
}
func TestPostUrlMediaPath(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
expected := "/user/" + user.Name() + "/posts/" + post.Id() + "/media/data.png"
assertions.AssertEqual(t, post.UrlMediaPath("data.png"), expected)
}
func TestPostUrlMediaPathWithSubDir(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
expected := "/user/" + user.Name() + "/posts/" + post.Id() + "/media/foo/data.png"
assertions.AssertEqual(t, post.UrlMediaPath("foo/data.png"), expected)
}
func TestDraftInMetaData(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := "---\n"
content += "title: test\n"
content += "draft: true\n"
@ -71,7 +71,7 @@ func TestDraftInMetaData(t *testing.T) {
func TestNoRawHTMLIfDisallowedByRepo(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := "---\n"
content += "title: test\n"
content += "draft: true\n"
@ -86,7 +86,7 @@ func TestNoRawHTMLIfDisallowedByRepo(t *testing.T) {
func TestRawHTMLIfAllowedByRepo(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{AllowRawHtml: true})
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := "---\n"
content += "title: test\n"
content += "draft: true\n"
@ -101,7 +101,7 @@ func TestRawHTMLIfAllowedByRepo(t *testing.T) {
func TestLoadMeta(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{AllowRawHtml: true})
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := "---\n"
content += "title: test\n"
@ -132,7 +132,7 @@ func TestLoadMeta(t *testing.T) {
func TestPersistIncomingWebmention(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
webmention := owl.WebmentionIn{
Source: "http://example.com/source",
}
@ -148,7 +148,7 @@ func TestAddIncomingWebmentionCreatesFile(t *testing.T) {
repo.HttpClient = &mocks.MockHttpClient{}
repo.Parser = &mocks.MockHtmlParser{}
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
err := post.AddIncomingWebmention("https://example.com")
assertions.AssertNoError(t, err, "Error adding webmention")
@ -162,7 +162,7 @@ func TestAddIncomingWebmentionNotOverwritingWebmention(t *testing.T) {
repo.HttpClient = &mocks.MockHttpClient{}
repo.Parser = &mocks.MockHtmlParser{}
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
post.PersistIncomingWebmention(owl.WebmentionIn{
Source: "https://example.com",
@ -182,7 +182,7 @@ func TestEnrichAddsTitle(t *testing.T) {
repo.HttpClient = &mocks.MockHttpClient{}
repo.Parser = &mocks.MockHtmlParser{}
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
post.AddIncomingWebmention("https://example.com")
post.EnrichWebmention(owl.WebmentionIn{Source: "https://example.com"})
@ -195,7 +195,7 @@ func TestEnrichAddsTitle(t *testing.T) {
func TestApprovedIncomingWebmentions(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
webmention := owl.WebmentionIn{
Source: "http://example.com/source",
ApprovalStatus: "approved",
@ -232,7 +232,7 @@ func TestApprovedIncomingWebmentions(t *testing.T) {
func TestScanningForLinks(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := "---\n"
content += "title: test\n"
@ -251,7 +251,7 @@ func TestScanningForLinks(t *testing.T) {
func TestScanningForLinksDoesNotAddDuplicates(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := "---\n"
content += "title: test\n"
@ -273,7 +273,7 @@ func TestScanningForLinksDoesNotAddDuplicates(t *testing.T) {
func TestScanningForLinksDoesAddReplyUrl(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := "---\n"
content += "title: test\n"
@ -296,7 +296,7 @@ func TestCanSendWebmention(t *testing.T) {
repo.HttpClient = &mocks.MockHttpClient{}
repo.Parser = &mocks.MockHtmlParser{}
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
webmention := owl.WebmentionOut{
Target: "http://example.com",
@ -317,7 +317,7 @@ func TestSendWebmentionOnlyScansOncePerWeek(t *testing.T) {
repo.HttpClient = &mocks.MockHttpClient{}
repo.Parser = &mocks.MockHtmlParser{}
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
webmention := owl.WebmentionOut{
Target: "http://example.com",
@ -342,7 +342,7 @@ func TestSendingMultipleWebmentions(t *testing.T) {
repo.HttpClient = &mocks.MockHttpClient{}
repo.Parser = &mocks.MockHtmlParser{}
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
wg := sync.WaitGroup{}
wg.Add(20)
@ -369,7 +369,7 @@ func TestReceivingMultipleWebmentions(t *testing.T) {
repo.HttpClient = &mocks.MockHttpClient{}
repo.Parser = &mocks.MockHtmlParser{}
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
wg := sync.WaitGroup{}
wg.Add(20)
@ -394,7 +394,7 @@ func TestSendingAndReceivingMultipleWebmentions(t *testing.T) {
repo.HttpClient = &mocks.MockHttpClient{}
repo.Parser = &mocks.MockHtmlParser{}
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
wg := sync.WaitGroup{}
wg.Add(40)
@ -433,7 +433,7 @@ func TestComplexParallelWebmentions(t *testing.T) {
},
}
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
wg := sync.WaitGroup{}
wg.Add(60)
@ -468,7 +468,7 @@ func TestComplexParallelWebmentions(t *testing.T) {
func TestPostWithoutContent(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser("testuser")
post, _ := user.CreateNewPostFull(owl.PostMeta{}, "")
post, _ := user.CreateNewPost(owl.PostMeta{}, "")
result := post.RenderedContent()
assertions.AssertEqual(t, result, "")
@ -486,7 +486,7 @@ func TestPostWithoutContent(t *testing.T) {
// },
// }
// user, _ := repo.CreateUser("testuser")
// post, _ := user.CreateNewPost("testpost", false)
// post, _ := user.CreateNewPostFull(owl.PostMeta{Type: "article", Title: "testpost"}, "")
// wg := sync.WaitGroup{}
// wg.Add(40)

View File

@ -11,7 +11,7 @@ import (
func TestCanRenderPost(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, err := owl.RenderPost(post)
assertions.AssertNoError(t, err, "Error rendering post")
@ -28,7 +28,7 @@ func TestRenderOneMe(t *testing.T) {
})
user.SetConfig(config)
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, err := owl.RenderPost(post)
assertions.AssertNoError(t, err, "Error rendering post")
@ -49,7 +49,7 @@ func TestRenderTwoMe(t *testing.T) {
})
user.SetConfig(config)
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, err := owl.RenderPost(post)
assertions.AssertNoError(t, err, "Error rendering post")
@ -60,7 +60,7 @@ func TestRenderTwoMe(t *testing.T) {
func TestRenderPostHEntry(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "class=\"h-entry\"")
assertions.AssertContains(t, result, "class=\"p-name\"")
@ -70,7 +70,7 @@ func TestRenderPostHEntry(t *testing.T) {
func TestRendererUsesBaseTemplate(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, err := owl.RenderPost(post)
assertions.AssertNoError(t, err, "Error rendering post")
@ -79,8 +79,8 @@ func TestRendererUsesBaseTemplate(t *testing.T) {
func TestCanRenderPostList(t *testing.T) {
user := getTestUser()
user.CreateNewPost("testpost1", false)
user.CreateNewPost("testpost2", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost1"}, "")
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost2"}, "")
result, err := owl.RenderPostList(user, &owl.PostList{
Id: "testlist",
Title: "Test List",
@ -95,8 +95,8 @@ func TestCanRenderPostList(t *testing.T) {
func TestCanRenderPostListNotIncludeOther(t *testing.T) {
user := getTestUser()
user.CreateNewPostFull(owl.PostMeta{Title: "testpost1", Type: "article"}, "testpost1")
user.CreateNewPostFull(owl.PostMeta{Title: "testpost2", Type: "note"}, "testpost2")
user.CreateNewPost(owl.PostMeta{Title: "testpost1", Type: "article"}, "testpost1")
user.CreateNewPost(owl.PostMeta{Title: "testpost2", Type: "note"}, "testpost2")
result, _ := owl.RenderPostList(user, &owl.PostList{
Id: "testlist",
Title: "Test List",
@ -110,9 +110,9 @@ func TestCanRenderPostListNotIncludeOther(t *testing.T) {
func TestCanRenderPostListNotIncludeMultiple(t *testing.T) {
user := getTestUser()
user.CreateNewPostFull(owl.PostMeta{Title: "testpost1", Type: "article"}, "testpost1")
user.CreateNewPostFull(owl.PostMeta{Title: "testpost2", Type: "note"}, "testpost2")
user.CreateNewPostFull(owl.PostMeta{Title: "testpost3", Type: "recipe"}, "testpost3")
user.CreateNewPost(owl.PostMeta{Title: "testpost1", Type: "article"}, "testpost1")
user.CreateNewPost(owl.PostMeta{Title: "testpost2", Type: "note"}, "testpost2")
user.CreateNewPost(owl.PostMeta{Title: "testpost3", Type: "recipe"}, "testpost3")
result, _ := owl.RenderPostList(user, &owl.PostList{
Id: "testlist",
Title: "Test List",
@ -127,8 +127,8 @@ func TestCanRenderPostListNotIncludeMultiple(t *testing.T) {
func TestCanRenderIndexPage(t *testing.T) {
user := getTestUser()
user.CreateNewPost("testpost1", false)
user.CreateNewPost("testpost2", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost1"}, "")
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost2"}, "")
result, _ := owl.RenderIndexPage(user)
assertions.AssertContains(t, result, "testpost1")
assertions.AssertContains(t, result, "testpost2")
@ -136,14 +136,14 @@ func TestCanRenderIndexPage(t *testing.T) {
func TestCanRenderIndexPageNoTitle(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPostFull(owl.PostMeta{}, "hi")
post, _ := user.CreateNewPost(owl.PostMeta{}, "hi")
result, _ := owl.RenderIndexPage(user)
assertions.AssertContains(t, result, post.Id())
}
func TestRenderNoteAsFullContent(t *testing.T) {
user := getTestUser()
user.CreateNewPostFull(owl.PostMeta{Type: "note"}, "This is a note")
user.CreateNewPost(owl.PostMeta{Type: "note"}, "This is a note")
result, _ := owl.RenderPostList(user, &owl.PostList{
Include: []string{"note"},
})
@ -153,7 +153,7 @@ func TestRenderNoteAsFullContent(t *testing.T) {
func TestIndexPageContainsHFeedContainer(t *testing.T) {
user := getTestUser()
user.CreateNewPost("testpost1", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost1"}, "")
result, _ := owl.RenderIndexPage(user)
assertions.AssertContains(t, result, "<div class=\"h-feed\">")
@ -161,7 +161,7 @@ func TestIndexPageContainsHFeedContainer(t *testing.T) {
func TestIndexPageContainsHEntryAndUUrl(t *testing.T) {
user := getTestUser()
user.CreateNewPost("testpost1", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost1"}, "")
result, _ := owl.RenderIndexPage(user)
assertions.AssertContains(t, result, "class=\"h-entry\"")
@ -171,7 +171,7 @@ func TestIndexPageContainsHEntryAndUUrl(t *testing.T) {
func TestIndexPageDoesNotContainsArticle(t *testing.T) {
user := getTestUser()
user.CreateNewPostFull(owl.PostMeta{Type: "article"}, "hi")
user.CreateNewPost(owl.PostMeta{Type: "article"}, "hi")
result, _ := owl.RenderIndexPage(user)
assertions.AssertContains(t, result, "class=\"h-entry\"")
@ -180,7 +180,7 @@ func TestIndexPageDoesNotContainsArticle(t *testing.T) {
func TestIndexPageDoesNotContainsReply(t *testing.T) {
user := getTestUser()
user.CreateNewPostFull(owl.PostMeta{Type: "reply", Reply: owl.ReplyData{Url: "https://example.com/post"}}, "hi")
user.CreateNewPost(owl.PostMeta{Type: "reply", Reply: owl.ReplyData{Url: "https://example.com/post"}}, "hi")
result, _ := owl.RenderIndexPage(user)
assertions.AssertContains(t, result, "class=\"h-entry\"")
@ -189,8 +189,8 @@ func TestIndexPageDoesNotContainsReply(t *testing.T) {
func TestRenderIndexPageWithBrokenBaseTemplate(t *testing.T) {
user := getTestUser()
user.CreateNewPost("testpost1", false)
user.CreateNewPost("testpost2", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost1"}, "")
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost2"}, "")
os.WriteFile(path.Join(user.Dir(), "meta/base.html"), []byte("{{content}}"), 0644)
@ -216,7 +216,7 @@ func TestRendersHeaderTitle(t *testing.T) {
SubTitle: "Test SubTitle",
HeaderColor: "#ff1337",
})
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "Test Title")
@ -226,7 +226,7 @@ func TestRendersHeaderTitle(t *testing.T) {
func TestRenderPostIncludesRelToWebMention(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "rel=\"webmention\"")
@ -236,7 +236,7 @@ func TestRenderPostIncludesRelToWebMention(t *testing.T) {
func TestRenderPostAddsLinksToApprovedWebmention(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
webmention := owl.WebmentionIn{
Source: "http://example.com/source3",
Title: "Test Title",
@ -260,7 +260,7 @@ func TestRenderPostAddsLinksToApprovedWebmention(t *testing.T) {
func TestRenderPostNotMentioningWebmentionsIfNoAvail(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, _ := owl.RenderPost(post)
assertions.AssertNotContains(t, result, "Webmention")
@ -269,7 +269,7 @@ func TestRenderPostNotMentioningWebmentionsIfNoAvail(t *testing.T) {
func TestRenderIncludesFullUrl(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "class=\"u-url\"")
@ -292,7 +292,7 @@ func TestAuthorNameInPost(t *testing.T) {
HeaderColor: "#ff1337",
AuthorName: "Test Author",
})
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "Test Author")
@ -301,7 +301,7 @@ func TestAuthorNameInPost(t *testing.T) {
func TestRenderReplyWithoutText(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPostFull(owl.PostMeta{
post, _ := user.CreateNewPost(owl.PostMeta{
Type: "reply",
Reply: owl.ReplyData{
Url: "https://example.com/post",
@ -315,7 +315,7 @@ func TestRenderReplyWithoutText(t *testing.T) {
func TestRenderReplyWithText(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPostFull(owl.PostMeta{
post, _ := user.CreateNewPost(owl.PostMeta{
Type: "reply",
Reply: owl.ReplyData{
Url: "https://example.com/post",
@ -331,7 +331,7 @@ func TestRenderReplyWithText(t *testing.T) {
func TestRengerPostContainsBookmark(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPostFull(owl.PostMeta{Type: "bookmark", Bookmark: owl.BookmarkData{Url: "https://example.com/post"}}, "hi")
post, _ := user.CreateNewPost(owl.PostMeta{Type: "bookmark", Bookmark: owl.BookmarkData{Url: "https://example.com/post"}}, "hi")
result, _ := owl.RenderPost(post)
assertions.AssertContains(t, result, "https://example.com/post")
@ -339,7 +339,7 @@ func TestRengerPostContainsBookmark(t *testing.T) {
func TestOpenGraphTags(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := "---\n"
content += "title: The Rock\n"
@ -430,7 +430,7 @@ func TestRenderHeaderMenuUrlItem(t *testing.T) {
func TestRenderHeaderMenuPost(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
user.AddHeaderMenuItem(owl.MenuItem{
Title: "Test Entry",
Post: post.Id(),
@ -464,7 +464,7 @@ func TestRenderFooterMenuUrlItem(t *testing.T) {
func TestRenderFooterMenuPost(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPostFull(owl.PostMeta{
post, _ := user.CreateNewPost(owl.PostMeta{
Type: "private",
}, "")
result, _ := owl.RenderIndexPage(user)

View File

@ -199,7 +199,7 @@ func TestSingleUserRepoUserUrlPathIsSimple(t *testing.T) {
func TestCanGetMapWithAllPostAliases(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
post, _ := user.CreateNewPost("test-1", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "test-1"}, "")
content := "---\n"
content += "title: Test\n"
@ -225,8 +225,8 @@ func TestCanGetMapWithAllPostAliases(t *testing.T) {
func TestAliasesHaveCorrectPost(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
post1, _ := user.CreateNewPost("test-1", false)
post2, _ := user.CreateNewPost("test-2", false)
post1, _ := user.CreateNewPost(owl.PostMeta{Title: "test-1"}, "")
post2, _ := user.CreateNewPost(owl.PostMeta{Title: "test-2"}, "")
content := "---\n"
content += "title: Test\n"

View File

@ -35,7 +35,7 @@ func TestRenderRSSFeedUserData(t *testing.T) {
func TestRenderRSSFeedPostData(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "testpost"}, "")
content := "---\n"
content += "title: Test Post\n"
@ -53,7 +53,7 @@ func TestRenderRSSFeedPostData(t *testing.T) {
func TestRenderRSSFeedPostDataWithoutDate(t *testing.T) {
user := getTestUser()
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Title: "testpost"}, "")
content := "---\n"
content += "title: Test Post\n"

17
user.go
View File

@ -300,7 +300,7 @@ func (user User) GetPost(id string) (IPost, error) {
return &post, nil
}
func (user User) CreateNewPostFull(meta PostMeta, content string) (IPost, error) {
func (user User) CreateNewPost(meta PostMeta, content string) (IPost, error) {
slugHint := meta.Title
if slugHint == "" {
slugHint = "note"
@ -321,6 +321,11 @@ func (user User) CreateNewPostFull(meta PostMeta, content string) (IPost, error)
}
post := Post{user: &user, id: folder_name}
// if date is not set, set it to now
if meta.Date.IsZero() {
meta.Date = time.Now()
}
initial_content := ""
initial_content += "---\n"
// write meta
@ -341,16 +346,6 @@ func (user User) CreateNewPostFull(meta PostMeta, content string) (IPost, error)
return user.GetPost(post.Id())
}
func (user User) CreateNewPost(title string, draft bool) (IPost, error) {
meta := PostMeta{
Title: title,
Date: time.Now(),
Aliases: []string{},
Draft: draft,
}
return user.CreateNewPostFull(meta, title)
}
func (user User) Template() (string, error) {
// load base.html
path := path.Join(user.Dir(), "meta", "base.html")

View File

@ -14,7 +14,7 @@ func TestCreateNewPostCreatesEntryInPublic(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
// Create a new post
user.CreateNewPost("testpost", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
files, err := os.ReadDir(path.Join(user.Dir(), "public"))
assertions.AssertNoError(t, err, "Error reading directory")
assertions.AssertLen(t, files, 1)
@ -25,7 +25,7 @@ func TestCreateNewPostCreatesMediaDir(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
// Create a new post
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
_, err := os.Stat(post.MediaDir())
assertions.AssertNot(t, os.IsNotExist(err), "Media directory not created")
}
@ -33,7 +33,7 @@ func TestCreateNewPostCreatesMediaDir(t *testing.T) {
func TestCreateNewPostAddsDateToMetaBlock(t *testing.T) {
user := getTestUser()
// Create a new post
user.CreateNewPost("testpost", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
posts, _ := user.PublishedPosts()
post, _ := user.GetPost(posts[0].Id())
meta := post.Meta()
@ -45,9 +45,9 @@ func TestCreateNewPostMultipleCalls(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
// Create a new post
user.CreateNewPost("testpost", false)
user.CreateNewPost("testpost", false)
user.CreateNewPost("testpost", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
files, err := os.ReadDir(path.Join(user.Dir(), "public"))
assertions.AssertNoError(t, err, "Error reading directory")
assertions.AssertEqual(t, len(files), 3)
@ -58,9 +58,9 @@ func TestCanListUserPosts(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
// Create a new post
user.CreateNewPost("testpost", false)
user.CreateNewPost("testpost", false)
user.CreateNewPost("testpost", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
posts, err := user.PublishedPosts()
assertions.AssertNoError(t, err, "Error reading posts")
assertions.AssertLen(t, posts, 3)
@ -71,7 +71,7 @@ func TestCannotListUserPostsInSubdirectories(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
// Create a new post
user.CreateNewPost("testpost", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
os.Mkdir(path.Join(user.PostDir(), "foo"), 0755)
os.Mkdir(path.Join(user.PostDir(), "foo/bar"), 0755)
content := ""
@ -108,7 +108,7 @@ func TestCannotListUserPostsWithoutIndexMd(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
// Create a new post
user.CreateNewPost("testpost", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
os.Mkdir(path.Join(user.PostDir(), "foo"), 0755)
os.Mkdir(path.Join(user.PostDir(), "foo/bar"), 0755)
content := ""
@ -137,7 +137,7 @@ func TestListUserPostsDoesNotIncludeDrafts(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
// Create a new post
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := ""
content += "---\n"
content += "title: test\n"
@ -156,7 +156,7 @@ func TestListUsersDraftsExcludedRealWorld(t *testing.T) {
repo := getTestRepo(owl.RepoConfig{})
user, _ := repo.CreateUser(randomUserName())
// Create a new post
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := ""
content += "---\n"
content += "title: Articles September 2019\n"
@ -180,7 +180,7 @@ func TestListUsersDraftsExcludedRealWorld(t *testing.T) {
func TestCanLoadPost(t *testing.T) {
user := getTestUser()
// Create a new post
user.CreateNewPost("testpost", false)
user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
posts, _ := user.PublishedPosts()
post, _ := user.GetPost(posts[0].Id())
@ -200,8 +200,8 @@ func TestUserFullUrl(t *testing.T) {
func TestPostsSortedByPublishingDateLatestFirst(t *testing.T) {
user := getTestUser()
// Create a new post
post1, _ := user.CreateNewPost("testpost", false)
post2, _ := user.CreateNewPost("testpost2", false)
post1, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
post2, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost2"}, "")
content := "---\n"
content += "title: Test Post\n"
@ -227,7 +227,7 @@ func TestPostsSortedByPublishingDateLatestFirst2(t *testing.T) {
// Create a new post
posts := []owl.IPost{}
for i := 59; i >= 0; i-- {
post, _ := user.CreateNewPost("testpost", false)
post, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
content := "---\n"
content += "title: Test Post\n"
content += fmt.Sprintf("date: Wed, 17 Aug 2022 10:%02d:02 +0000\n", i)
@ -246,8 +246,8 @@ func TestPostsSortedByPublishingDateLatestFirst2(t *testing.T) {
func TestPostsSortedByPublishingDateBrokenAtBottom(t *testing.T) {
user := getTestUser()
// Create a new post
post1, _ := user.CreateNewPost("testpost", false)
post2, _ := user.CreateNewPost("testpost2", false)
post1, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost"}, "")
post2, _ := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost2"}, "")
content := "---\n"
content += "title: Test Post\n"
@ -281,7 +281,7 @@ func TestAvatarSetIfFileExist(t *testing.T) {
func TestPostNameIllegalFileName(t *testing.T) {
user := getTestUser()
_, err := user.CreateNewPost("testpost?///", false)
_, err := user.CreateNewPost(owl.PostMeta{Type: "article", Title: "testpost?///"}, "")
assertions.AssertNoError(t, err, "Should not have failed")
}