Beispiel #1
0
func Test_LoadArticleIndex(t *testing.T) {
	a := assert.New(t)

	datastore.DeleteArtilcles("*****@*****.**")

	article := datastore.ParseEntry(fakeFileMetaData(), fakeFileContentWithNoMetadata())
	article.Path = "p1"
	article.Permalink = "a1"
	article.CreatedAt = "2014-12-01"
	article.GenerateID("*****@*****.**")
	article.Save()
	anotherArticle := datastore.ParseEntry(fakeFileMetaData(), fakeFileContentWithNoMetadata())
	article.Path = "p2"
	anotherArticle.Permalink = "a2"
	anotherArticle.Title = "t2"
	anotherArticle.CreatedAt = "2014-12-02"
	anotherArticle.GenerateID("*****@*****.**")
	anotherArticle.Save()

	datastore.ArticlesReindex("*****@*****.**")
	index := datastore.LoadArticleIndex("*****@*****.**")

	a.Contains(index[0].Permalink, "a2")
	a.Contains(index[0].ID, anotherArticle.ID)
	a.Contains(index[0].Title, "t2")
	a.Contains(index[0].Summary, "this is a pragraph")
	a.Contains(index[0].CreatedAt, "2014-12-02")
}
Beispiel #2
0
func Test_DeleteArticles(t *testing.T) {
	a := assert.New(t)
	article := datastore.ParseEntry(fakeFileMetaData(), fakeFileContentWithNoMetadata())
	article.GenerateID("*****@*****.**")
	article.Save()
	datastore.DeleteArtilcles("*****@*****.**")
	a.Equal(len(datastore.LoadArticleIndex("*****@*****.**")), 0)
}