feat: storage, language rules and migration
This commit is contained in:
1 parent
8c4a1825ab
commit
0806733d5c
70 files changed
+1771
-132
No files matched your search
@@ -237,7 +237,7 @@ func TestSeoDataMigrationBackfill(t *testing.T) {
|
||||
migrateSeo(t, db)
|
||||
|
||||
found, err := persistence.NewArticleRepository(db).Get(1)
|
||||
want := article.Article{ID: 1, Title: "News", Body: "Body", SiteID: 1, Slug: "news", SEODismissed: []string{}, Authors: found.Authors, CreatedAt: found.CreatedAt, UpdatedAt: found.UpdatedAt}
|
||||
want := article.Article{ID: 1, Title: "News", Body: "Body", SiteID: 1, Slug: "news", SEODismissed: []string{}, Authors: found.Authors, CreatedAt: found.CreatedAt, UpdatedAt: found.UpdatedAt, StoryID: 1, ContentRevision: 1}
|
||||
if err != nil || !reflect.DeepEqual(found, want) {
|
||||
t.Errorf("found %+v, %v", found, err)
|
||||
}
|
||||
@@ -251,7 +251,7 @@ func TestSeoDataMigrationBackfill(t *testing.T) {
|
||||
if !db.Migrator().HasIndex(&entity.Article{}, "idx_articles_site_slug") {
|
||||
t.Fatal("the index is missing")
|
||||
}
|
||||
duplicate := entity.Article{Title: "Again", SiteID: 1, Slug: "news"}
|
||||
duplicate := entity.Article{StoryID: fixtureStory(), Title: "Again", SiteID: 1, Slug: "news"}
|
||||
if err := db.Create(&duplicate).Error; err == nil {
|
||||
t.Error("a duplicate (site_id, slug) was accepted")
|
||||
}
|
||||
@@ -299,7 +299,7 @@ func TestSeoDataArticleRepositoryContract(t *testing.T) {
|
||||
|
||||
_, duplicate := articles.Create(article.Article{Title: "Two", SiteID: siteID, Slug: "spring"})
|
||||
_, elsewhere := articles.Create(article.Article{Title: "Three", SiteID: other.ID, Slug: "spring"})
|
||||
rawDuplicate := db.Create(&entity.Article{Title: "Four", SiteID: siteID, Slug: "spring"}).Error
|
||||
rawDuplicate := db.Create(&entity.Article{StoryID: fixtureStory(), Title: "Four", SiteID: siteID, Slug: "spring"}).Error
|
||||
|
||||
if !errors.Is(duplicate, article.ErrSlugTaken) || elsewhere != nil || rawDuplicate == nil {
|
||||
t.Errorf("duplicate %v, elsewhere %v, raw %v", duplicate, elsewhere, rawDuplicate)
|
||||
@@ -346,10 +346,10 @@ func TestSeoDataArticleRepositoryContract(t *testing.T) {
|
||||
{"slug taken ignores the article itself and a deleted article frees its slug", func(t *testing.T, db *gorm.DB, articles *persistence.ArticleRepository, siteID uint32) {
|
||||
created, _ := articles.Create(article.Article{Title: "One", SiteID: siteID, Slug: "spring"})
|
||||
|
||||
own, ownErr := articles.SlugTaken(siteID, "spring", created.ID)
|
||||
other, otherErr := articles.SlugTaken(siteID, "spring", 0)
|
||||
own, ownErr := articles.SlugTaken(siteID, "", "spring", created.ID)
|
||||
other, otherErr := articles.SlugTaken(siteID, "", "spring", 0)
|
||||
deleteErr := articles.Delete(created.ID)
|
||||
afterDelete, afterErr := articles.SlugTaken(siteID, "spring", 0)
|
||||
afterDelete, afterErr := articles.SlugTaken(siteID, "", "spring", 0)
|
||||
_, recreated := articles.Create(article.Article{Title: "Again", SiteID: siteID, Slug: "spring"})
|
||||
|
||||
if ownErr != nil || otherErr != nil || afterErr != nil || own || !other || deleteErr != nil || afterDelete || recreated != nil {
|
||||
|
||||
Reference in new issue
Block a user