refac: article reads, story delete, no leaks, stored SEO status, rate limit, cleanup (%site%, article repo split, old lang repos, one default per site rule to domain)
This commit is contained in:
1 parent
9d284e65a9
commit
7c15206170
85 files changed
+1788
-593
No files matched your search
@@ -3,6 +3,7 @@ package test
|
||||
import (
|
||||
"RenewCMS/internal/domain/article"
|
||||
"RenewCMS/internal/domain/language"
|
||||
"RenewCMS/internal/domain/localization"
|
||||
"RenewCMS/internal/domain/site"
|
||||
"RenewCMS/internal/domain/transaction"
|
||||
"context"
|
||||
@@ -10,35 +11,60 @@ import (
|
||||
)
|
||||
|
||||
type mockStartingLanguages struct {
|
||||
site.Repository
|
||||
confirmed map[uint32]string
|
||||
locked []uint32
|
||||
failWith error
|
||||
removed map[uint32]bool
|
||||
}
|
||||
|
||||
var _ language.Repository = &mockStartingLanguages{}
|
||||
var _ localization.Repository = &mockStartingLanguages{}
|
||||
|
||||
func (m *mockStartingLanguages) ListBySite(siteID uint32) ([]language.SiteLanguage, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockStartingLanguages) MarkConfirmed(siteID uint32, tag string) error {
|
||||
func (m *mockStartingLanguages) LockSite(siteID uint32) error {
|
||||
m.locked = append(m.locked, siteID)
|
||||
if m.failWith != nil {
|
||||
return m.failWith
|
||||
}
|
||||
if m.removed[siteID] {
|
||||
return site.ErrSiteNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockStartingLanguages) LockSiteLanguages(siteID uint32) ([]language.SiteLanguage, error) {
|
||||
m.locked = append(m.locked, siteID)
|
||||
if m.failWith != nil {
|
||||
return nil, m.failWith
|
||||
}
|
||||
if m.removed[siteID] {
|
||||
return nil, site.ErrSiteNotFound
|
||||
}
|
||||
func (m *mockStartingLanguages) Rows(siteID uint32) ([]localization.Row, error) {
|
||||
tag, confirmed := m.confirmed[siteID]
|
||||
if !confirmed || tag == language.Unassigned {
|
||||
return nil, nil
|
||||
}
|
||||
return []language.SiteLanguage{{SiteID: siteID, Tag: tag, IsDefault: true, Enabled: true, Confirmed: true}}, nil
|
||||
return []localization.Row{{Tag: tag, IsDefault: true, Enabled: true, Confirmed: true}}, nil
|
||||
}
|
||||
|
||||
func (m *mockStartingLanguages) ConfirmedSites() (map[uint32]bool, error) {
|
||||
return map[uint32]bool{}, nil
|
||||
}
|
||||
|
||||
func (m *mockStartingLanguages) VersionCounts(siteID uint32) (map[string]localization.VersionCount, error) {
|
||||
return map[string]localization.VersionCount{}, nil
|
||||
}
|
||||
|
||||
func (m *mockStartingLanguages) Replace(siteID uint32, rows []localization.Row) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockStartingLanguages) ConfirmSetup(siteID uint32, tag string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type removableSites struct {
|
||||
*mockSiteRepo
|
||||
removed map[uint32]bool
|
||||
}
|
||||
|
||||
func (r removableSites) LockSite(siteID uint32) error {
|
||||
if r.removed[siteID] {
|
||||
return site.ErrSiteNotFound
|
||||
}
|
||||
return r.mockSiteRepo.LockSite(siteID)
|
||||
}
|
||||
|
||||
type mockCreateTransactor struct {
|
||||
@@ -51,7 +77,7 @@ var _ transaction.Transactor = &mockCreateTransactor{}
|
||||
|
||||
func (m *mockCreateTransactor) Run(ctx context.Context, work func(transaction.Repositories) error) error {
|
||||
m.runs++
|
||||
return work(transaction.Repositories{Articles: m.articles, Languages: m.languages})
|
||||
return work(transaction.Repositories{Articles: m.articles, Sites: m.languages, Localization: m.languages})
|
||||
}
|
||||
|
||||
func passthroughCreateTransactor(articles article.Repository) *mockCreateTransactor {
|
||||
|
||||
Reference in new issue
Block a user