feat: public API, SEO and existing surfaces
This commit is contained in:
1 parent
45fbbc33b1
commit
c390fcfe8d
103 files changed
+4476
-231
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
domainArticle "RenewCMS/internal/domain/article"
|
||||
"RenewCMS/internal/domain/localization"
|
||||
"RenewCMS/internal/domain/site"
|
||||
"RenewCMS/internal/infrastructure/persistence/database"
|
||||
@@ -229,6 +230,47 @@ func TestLocalizationPersistence(t *testing.T) {
|
||||
t.Errorf("retry = %+v, %v", again, err)
|
||||
}
|
||||
}},
|
||||
{"Exact lookup and story resolution read the same rows", func(t *testing.T, db *gorm.DB) {
|
||||
created := seedLocalizedSite(t, db, "lookups", nil, nil)
|
||||
repository := persistence.NewArticleRepository(db)
|
||||
story := fixtureStory()
|
||||
published := entity.Article{Title: "Published", SiteID: created.ID, Lang: "fr", StoryID: story, Slug: "publie", IsOnline: true}
|
||||
offline := entity.Article{Title: "Offline", SiteID: created.ID, Lang: "en", StoryID: story, Slug: "offline"}
|
||||
unassigned := entity.Article{Title: "Unassigned", SiteID: created.ID, StoryID: fixtureStory(), Slug: "legacy", IsOnline: true}
|
||||
removed := entity.Article{Title: "Removed", SiteID: created.ID, Lang: "de", StoryID: story, Slug: "weg", IsOnline: true}
|
||||
for _, stored := range []*entity.Article{&published, &offline, &unassigned, &removed} {
|
||||
if err := db.Create(stored).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := db.Delete(&removed).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
found, err := repository.GetByLangSlug(created.ID, "fr", "publie")
|
||||
missingLanguage, missingErr := repository.GetByLangSlug(created.ID, "en", "publie")
|
||||
_, removedErr := repository.GetByLangSlug(created.ID, "de", "weg")
|
||||
_, unassignedErr := repository.GetByLangSlug(created.ID, "en", "legacy")
|
||||
versions, listErr := repository.ListByStory(story)
|
||||
|
||||
if err != nil || found.ID != published.ID || !found.IsOnline {
|
||||
t.Errorf("exact lookup = %+v, %v", found, err)
|
||||
}
|
||||
if !errors.Is(missingErr, domainArticle.ErrArticleNotFound) || missingLanguage.ID != 0 || !errors.Is(removedErr, domainArticle.ErrArticleNotFound) || !errors.Is(unassignedErr, domainArticle.ErrArticleNotFound) {
|
||||
t.Errorf("misses = %v %v %v", missingErr, removedErr, unassignedErr)
|
||||
}
|
||||
if listErr != nil || len(versions) != 2 {
|
||||
t.Errorf("story versions = %d, %v", len(versions), listErr)
|
||||
}
|
||||
for _, name := range []string{"idx_articles_site_slug", "idx_articles_story_lang"} {
|
||||
if !db.Migrator().HasIndex(&entity.Article{}, name) {
|
||||
t.Errorf("index %s is missing", name)
|
||||
}
|
||||
}
|
||||
if err := database.Migrate(db, migrationPublicURL); err != nil {
|
||||
t.Errorf("a second migration failed: %v", err)
|
||||
}
|
||||
}},
|
||||
}
|
||||
for _, backend := range backends {
|
||||
for _, c := range cases {
|
||||
|
||||
Reference in new issue
Block a user