diff --git a/cmd/owl/new_post.go b/cmd/owl/new_post.go index 4c22e21..df0d3e7 100644 --- a/cmd/owl/new_post.go +++ b/cmd/owl/new_post.go @@ -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 { diff --git a/cmd/owl/web/aliases_test.go b/cmd/owl/web/aliases_test.go index 2c6977b..b941e5a 100644 --- a/cmd/owl/web/aliases_test.go +++ b/cmd/owl/web/aliases_test.go @@ -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" diff --git a/cmd/owl/web/editor_handler.go b/cmd/owl/web/editor_handler.go index 5ecf267..c095e65 100644 --- a/cmd/owl/web/editor_handler.go +++ b/cmd/owl/web/editor_handler.go @@ -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, diff --git a/cmd/owl/web/editor_test.go b/cmd/owl/web/editor_test.go index 7c5878a..edd354d 100644 --- a/cmd/owl/web/editor_test.go +++ b/cmd/owl/web/editor_test.go @@ -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() diff --git a/cmd/owl/web/handler.go b/cmd/owl/web/handler.go index 76d5eb6..6541b91 100644 --- a/cmd/owl/web/handler.go +++ b/cmd/owl/web/handler.go @@ -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{ diff --git a/cmd/owl/web/multi_user_test.go b/cmd/owl/web/multi_user_test.go index 1772596..74acc10 100644 --- a/cmd/owl/web/multi_user_test.go +++ b/cmd/owl/web/multi_user_test.go @@ -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") diff --git a/cmd/owl/web/post_test.go b/cmd/owl/web/post_test.go index f593588..11c9dc9 100644 --- a/cmd/owl/web/post_test.go +++ b/cmd/owl/web/post_test.go @@ -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" diff --git a/cmd/owl/web/rss_test.go b/cmd/owl/web/rss_test.go index 20b5fa4..6ac5f83 100644 --- a/cmd/owl/web/rss_test.go +++ b/cmd/owl/web/rss_test.go @@ -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) diff --git a/cmd/owl/web/single_user_test.go b/cmd/owl/web/single_user_test.go index a632d54..1ab409d 100644 --- a/cmd/owl/web/single_user_test.go +++ b/cmd/owl/web/single_user_test.go @@ -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") diff --git a/cmd/owl/web/webmention_test.go b/cmd/owl/web/webmention_test.go index 6806149..84faf3e 100644 --- a/cmd/owl/web/webmention_test.go +++ b/cmd/owl/web/webmention_test.go @@ -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" diff --git a/cmd/owl/webmention.go b/cmd/owl/webmention.go index 35cbbd9..3a61810 100644 --- a/cmd/owl/webmention.go +++ b/cmd/owl/webmention.go @@ -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() diff --git a/post.go b/post.go index caf2794..56bf49c 100644 --- a/post.go +++ b/post.go @@ -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:] diff --git a/post_test.go b/post_test.go index 898bf72..ad23343 100644 --- a/post_test.go +++ b/post_test.go @@ -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) diff --git a/renderer_test.go b/renderer_test.go index 81c3024..ee49d80 100644 --- a/renderer_test.go +++ b/renderer_test.go @@ -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, "