Documentation
¶
Overview ¶
Package fake holds in-memory implementations of the services the theme engine and the site front controller consume (content, taxonomy, media, menus, redirects, seo), for tests. They are deliberately simple: slices and maps guarded by a mutex, no validation beyond what tests need.
Index ¶
- Variables
- type Content
- func (c *Content) Add(it content.Item) content.Item
- func (c *Content) Create(_ context.Context, in content.Input) (*content.Item, error)
- func (c *Content) CreateTranslation(context.Context, string, string) (*content.Item, error)
- func (c *Content) Delete(_ context.Context, id string, _ bool) error
- func (c *Content) DeleteType(_ context.Context, slug string) error
- func (c *Content) Get(_ context.Context, id string) (*content.Item, error)
- func (c *Content) GetBySlug(_ context.Context, typ, slug, locale string) (*content.Item, error)
- func (c *Content) GetType(_ context.Context, slug string) (*content.Type, error)
- func (c *Content) LinkTranslation(context.Context, string, string) error
- func (c *Content) LinkTranslationGuarded(context.Context, string, string, []string) error
- func (c *Content) Publish(_ context.Context, id string) error
- func (c *Content) Query(_ context.Context, q content.Query) (content.Page[content.Item], error)
- func (c *Content) Reindex(context.Context) error
- func (c *Content) Restore(ctx context.Context, id, _ string) (*content.Item, error)
- func (c *Content) Revisions(context.Context, string) ([]content.Revision, error)
- func (c *Content) SaveType(_ context.Context, t content.Type) error
- func (c *Content) Translations(ctx context.Context, id string) ([]content.Item, error)
- func (c *Content) Types(context.Context) ([]content.Type, error)
- func (c *Content) UnlinkTranslation(context.Context, string) error
- func (c *Content) Unpublish(_ context.Context, id string) error
- func (c *Content) Update(_ context.Context, id string, in content.Input) (*content.Item, error)
- func (c *Content) Validate(_ *content.Type, fields map[string]any) (map[string]any, content.FieldErrors)
- type Media
- func (s *Media) Add(m media.Media)
- func (s *Media) Delete(_ context.Context, id string) error
- func (s *Media) FindBySourceURL(context.Context, string) (*media.Media, error)
- func (s *Media) FromURL(context.Context, string, media.UploadMeta) (*media.Media, error)
- func (s *Media) Get(_ context.Context, id string) (*media.Media, error)
- func (s *Media) List(context.Context, media.ListQuery) ([]media.Media, int, error)
- func (s *Media) URL(m *media.Media, variant string) string
- func (s *Media) Update(ctx context.Context, id string, _ media.Patch) (*media.Media, error)
- func (s *Media) Upload(context.Context, string, io.Reader, media.UploadMeta) (*media.Media, error)
- type Menus
- func (s *Menus) ByLocation(_ context.Context, loc string) (*menus.Menu, error)
- func (s *Menus) ByLocationLocale(ctx context.Context, loc, locale string) (*menus.Menu, error)
- func (s *Menus) Delete(_ context.Context, id string) error
- func (s *Menus) Get(_ context.Context, slug string) (*menus.Menu, error)
- func (s *Menus) List(context.Context) ([]menus.Menu, error)
- func (s *Menus) Save(_ context.Context, m menus.Menu) (*menus.Menu, error)
- func (s *Menus) SaveItems(context.Context, string, []menus.Item) error
- type Module
- type Redirects
- func (s *Redirects) Delete(context.Context, string) error
- func (s *Redirects) Hit(context.Context, string)
- func (s *Redirects) List(context.Context, redirects.ListQuery) ([]redirects.Redirect, int, error)
- func (s *Redirects) Lookup(_ context.Context, path string) (*redirects.Redirect, bool)
- func (s *Redirects) Save(_ context.Context, r redirects.Redirect) (*redirects.Redirect, error)
- type SEO
- type Taxonomy
- func (s *Taxonomy) AddTerm(t taxonomy.Term) taxonomy.Term
- func (s *Taxonomy) ContentIDs(context.Context, string, []string) ([]string, error)
- func (s *Taxonomy) ContentTerms(context.Context, string) (map[string][]string, error)
- func (s *Taxonomy) Delete(_ context.Context, slug string) error
- func (s *Taxonomy) DeleteTerm(_ context.Context, id string) error
- func (s *Taxonomy) Get(_ context.Context, slug string) (*taxonomy.Taxonomy, error)
- func (s *Taxonomy) GetTerm(_ context.Context, id string) (*taxonomy.Term, error)
- func (s *Taxonomy) GetTermBySlug(_ context.Context, tax, slug string) (*taxonomy.Term, error)
- func (s *Taxonomy) Save(_ context.Context, t taxonomy.Taxonomy) error
- func (s *Taxonomy) SaveTerm(_ context.Context, t taxonomy.Term) (*taxonomy.Term, error)
- func (s *Taxonomy) SetContentTerms(context.Context, string, map[string][]string) error
- func (s *Taxonomy) Taxonomies(context.Context) ([]taxonomy.Taxonomy, error)
- func (s *Taxonomy) Terms(_ context.Context, tax string, _ taxonomy.TermQuery) ([]taxonomy.Term, int, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("fake: not found")
ErrNotFound is returned by the fakes that have no package sentinel.
Functions ¶
This section is empty.
Types ¶
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
Content is an in-memory content.Service.
func NewContent ¶
func NewContent() *Content
NewContent returns a store seeded with the system types post and page.
func (*Content) CreateTranslation ¶
func (*Content) GetBySlug ¶
GetBySlug matches locale exactly ("" matches only items without a locale).
func (*Content) LinkTranslation ¶
func (*Content) LinkTranslationGuarded ¶
func (*Content) Query ¶
Query supports Type, Status, Search, ParentID, Locale, Taxonomy (any of the slugs), Fields (eq only), Order (published_at, title, menu_order) and paging (default 10 per page).
func (*Content) Translations ¶
Translations returns the item alone: the fake has no translation groups.
func (*Content) UnlinkTranslation ¶
type Media ¶
type Media struct {
// contains filtered or unexported fields
}
Media is an in-memory media.Service keyed by ID.
func (*Media) FindBySourceURL ¶
type Menus ¶
type Menus struct {
// contains filtered or unexported fields
}
Menus is an in-memory menus.Service. It does not apply the "menus.resolve_url" filter; the theme fills empty URLs itself.
func (*Menus) ByLocation ¶
func (*Menus) ByLocationLocale ¶
ByLocationLocale prefers the menu of locale, then the one for every locale.
type Module ¶
type Module struct {
Content *Content
Taxonomy *Taxonomy
Media *Media
Menus *Menus
Redirects *Redirects
SEO seo.Service
}
Module registers the non-nil fakes under the kernel.Service* names. Put it before theme in the module list; its name is outside kernel.BootOrder.
type Redirects ¶
type Redirects struct {
// contains filtered or unexported fields
}
Redirects is an in-memory redirects.Service keyed by from path.
func NewRedirects ¶
NewRedirects returns the store with the given redirects.
type SEO ¶
type SEO struct{}
SEO renders a <title> and description meta; Sitemap and Robots return fixed bodies tests can assert on.
type Taxonomy ¶
type Taxonomy struct {
// contains filtered or unexported fields
}
Taxonomy is an in-memory taxonomy.Service seeded with category and tag.