Help us shape the future of Go! Take the 2026 Go Developer Survey

contenttest

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package contenttest runs one set of behaviour cases against any content, type, site setting or user setting store.

Index

Constants

View Source
const DefaultAuthor = "Maria Perez"

DefaultAuthor is the name the suite gives the account most cases write as.

Variables

This section is empty.

Functions

func AddressOf

func AddressOf(t *testing.T, store content.Store, id uuid.UUID) string

AddressOf returns the address the store holds for the item.

func AutosaveValuesOf

func AutosaveValuesOf(t *testing.T, store content.Store, item content.Content, author uuid.UUID) content.Values

AutosaveValuesOf returns the field values the author's autosave of the item holds.

func CarType

func CarType(t *testing.T) content.Type

CarType returns a car content type ready to store.

func CategoryType

func CategoryType() content.Type

CategoryType returns a content type items may be filed under.

func DeclareFields

func DeclareFields(t *testing.T, types content.TypeStore, fields ...content.Field) content.Group

DeclareFields stores a group on the post type declaring the fields in order, and returns the group holding them.

func DeclareFlexible

func DeclareFlexible(t *testing.T, types content.TypeStore) content.Field

DeclareFlexible stores a flexible field named features in the group keyed after the car type and returns it.

func DeclareLayout

func DeclareLayout(t *testing.T, types content.TypeStore, parentID int, key string) content.Field

DeclareLayout stores a layout under the flexible and returns it.

func DeclareOnType

func DeclareOnType(t *testing.T, types content.TypeStore, typeKey string, f content.Field) content.Field

DeclareOnType stores the field inside the group keyed after the type and returns it.

func DeclareRepeater

func DeclareRepeater(t *testing.T, types content.TypeStore, key string) content.Field

DeclareRepeater stores a repeater at the top of the car type inside the group keyed after the type and returns it.

func DeclareSection

func DeclareSection(t *testing.T, types content.TypeStore, key string) content.Field

DeclareSection stores a section at the top of the car type inside the group keyed after the type and returns it.

func DeclareTypedField

func DeclareTypedField(t *testing.T, types content.TypeStore, typeKey, key string) content.Field

DeclareTypedField stores a text field on the type inside the group keyed after the type.

func DeclareUnder

func DeclareUnder(t *testing.T, types content.TypeStore, parentID int, key string) content.Field

DeclareUnder stores a text sub field under the parent and returns it.

func DeclaredInside

func DeclaredInside(
	t *testing.T, types content.TypeStore, parent content.Field, key string, kind content.FieldKind,
) content.Field

DeclaredInside declares a sub field of the kind under the parent and returns it.

func DeclaredInto

func DeclaredInto(t *testing.T, registry *content.Registry)

DeclaredInto stores one plugin's type, group and field through the registry.

func DeclaredSectionInto

func DeclaredSectionInto(t *testing.T, registry *content.Registry) (content.Field, content.Field)

DeclaredSectionInto stores a plugin's group holding a section with one sub field, and returns both fields.

func EditTitle

func EditTitle(p content.Content, title string) content.Content

EditTitle returns the post with a new title and a later timestamp.

func FieldOn

func FieldOn(t *testing.T, typeKey, key string, kind content.FieldKind, relatesTo string) content.Field

FieldOn returns a field definition ready to declare on the type.

func FieldsGroupOf

func FieldsGroupOf(t *testing.T, types content.TypeStore, typeKey string) content.Group

FieldsGroupOf returns the group keyed after the type, stored at the type's own location when no group holds the key.

func FileUnder

func FileUnder(t *testing.T, store content.Store, post content.Content, targets ...uuid.UUID) content.Content

FileUnder points the post's categories at the targets and stores it.

func FlatPage

func FlatPage() content.Type

FlatPage returns the page type told to stop nesting.

func GroupAt

func GroupAt(t *testing.T, types content.TypeStore, id int) content.Group

GroupAt returns the stored group carrying the identity with its fields.

func GroupHolding

func GroupHolding(t *testing.T, types content.TypeStore, key string) int

GroupHolding returns the id of the stored group declaring the key.

func GroupOf

func GroupOf(groups []content.Group, id int) (content.Group, bool)

GroupOf returns the group carrying the identifier, and whether one does.

func GroupOn

func GroupOn(t *testing.T, types content.TypeStore, title, typeKey string) content.Group

GroupOn stores an active group placed on the type and returns it.

func HeldTargets

func HeldTargets(t *testing.T, c content.Content) []uuid.UUID

HeldTargets returns the identities the item's categories value names.

func Holding

func Holding(
	t *testing.T, store content.Store, title string, author uuid.UUID, values content.Values,
) content.Content

Holding stores a draft post carrying the given field values.

func LocationOf

func LocationOf(typeKey string) content.Rules

LocationOf returns a one rule location naming the type.

func MustAutosave

func MustAutosave(t *testing.T, p content.Content, author uuid.UUID) content.Revision

MustAutosave returns an autosave of the post credited to author.

func MustCreate

func MustCreate(t *testing.T, store content.Store, title string, author uuid.UUID) content.Content

MustCreate stores a draft post with the given title.

func MustFlexible

func MustFlexible(t *testing.T, key string) content.Field

MustFlexible returns a flexible sub field ready to stand inside a container.

func MustNest

func MustNest(
	t *testing.T, store content.Store, parent *content.Content, title string, author uuid.UUID,
) content.Content

MustNest stores a page under the parent and returns it.

func MustPost

func MustPost(t *testing.T, title string, author uuid.UUID) content.Content

MustPost returns a draft post with the given title.

func MustSnapshot

func MustSnapshot(t *testing.T, p content.Content, author uuid.UUID) *content.Revision

MustSnapshot returns a revision of the post credited to author.

func NamedTargets

func NamedTargets(targets []uuid.UUID) []any

NamedTargets returns the identities as a relation value stores them.

func PageType

func PageType() content.Type

PageType returns a hierarchical page type answering under pages.

func ParkValues

func ParkValues(t *testing.T, store content.Store, item content.Content, author uuid.UUID, values content.Values)

ParkValues stores the author's autosave of the item holding the values.

func PointedAtBy

func PointedAtBy(t *testing.T, store content.Store, target uuid.UUID) int

PointedAtBy returns how many published items point at the target through any field.

func PostField

func PostField(key string, kind content.FieldKind) content.Field

PostField returns a field of the kind on the post type under the key.

func PostType

func PostType() content.Type

PostType returns the built-in post type as every store registers it.

func Publish

func Publish(t *testing.T, store content.Store, title string, author uuid.UUID, at time.Time) content.Content

Publish stores a post already published at the given time.

func PublishItem

func PublishItem(t *testing.T, store content.Store, c content.Content) content.Content

PublishItem takes stored content public and returns it.

func ReadersOn

func ReadersOn(t *testing.T, types content.TypeStore, typeKey, relation string) (content.Group, content.Field)

ReadersOn stores a group on the type holding a backlinks field that reads the named relation, and returns both.

func RegisterCategoryType

func RegisterCategoryType(t *testing.T, types content.TypeStore)

RegisterCategoryType stores the category type so posts may point at categories.

func RegisterPageType

func RegisterPageType(t *testing.T, types content.TypeStore)

RegisterPageType stores the hierarchical page type so pages can nest.

func RelateToCategories

func RelateToCategories(t *testing.T, types content.TypeStore)

RelateToCategories registers the category type and declares the categories relation on the post type.

func RelationInside

func RelationInside(t *testing.T, types content.TypeStore, parent content.Field, key string) content.Field

RelationInside declares a relation pointing at cars inside the container and returns it.

func Rested

func Rested(t *testing.T, types content.TypeStore, title string) content.Group

Rested turns off the group the title names and returns it.

func RestingTwinOf

func RestingTwinOf(t *testing.T, types content.TypeStore, key string) content.Field

RestingTwinOf stores a resting group on car holding a section under the key and returns the section.

func RevisionValuesOf

func RevisionValuesOf(t *testing.T, store content.Store, revision content.Revision) content.Values

RevisionValuesOf returns the field values the store holds for the revision.

func RivalOnTruck

func RivalOnTruck(t *testing.T, types content.TypeStore, key string) content.Group

RivalOnTruck stores a truck group holding a section under the key, registers truck and returns the group.

func RowsFiledUnder

func RowsFiledUnder(targets ...uuid.UUID) content.Values

RowsFiledUnder returns the rows value pointing at every target through the relation inside it.

func RowsPointing

func RowsPointing(t *testing.T, types content.TypeStore) content.Field

RowsPointing declares a repeater on posts holding a relation that points at categories, and returns the relation.

func Run

func Run(t *testing.T, fresh Factory)

Run runs every content store case in parallel, each on stores of its own.

func RunSiteSettings

func RunSiteSettings(t *testing.T, fresh Factory)

RunSiteSettings runs every site setting store case in parallel, each on stores of its own.

func RunTypes

func RunTypes(t *testing.T, fresh Factory)

RunTypes runs every type store case in parallel, each on stores of its own.

func RunUserSettings

func RunUserSettings(t *testing.T, fresh Factory)

RunUserSettings runs every user setting store case in parallel, each on stores of its own.

func SectionChainOnCar

func SectionChainOnCar(t *testing.T, types content.TypeStore, registry *content.Registry, depth int) content.Field

SectionChainOnCar returns the deepest section of a chain nested depth levels under a top section of the car type.

func SectionOn

func SectionOn(t *testing.T, key string) content.Field

SectionOn returns a section field ready to nest under a parent.

func ServingEverything

func ServingEverything(t *testing.T, types content.TypeStore) content.Group

ServingEverything stores a group matching every type and returns it.

func StalePage

func StalePage(t *testing.T, parent *content.Content, title string, author uuid.UUID) content.Content

StalePage returns a page built against the type as it nested, filed under the parent.

func StillStored

func StillStored(t *testing.T, store content.Store, item content.Content) bool

StillStored reports whether the store still holds the item.

func StoreItem

func StoreItem(
	t *testing.T, store content.Store, kind content.Type, parent *content.Content, title string, author uuid.UUID,
) content.Content

StoreItem stores an item of the type under the parent and returns it.

func StoreType

func StoreType(t *testing.T, types content.TypeStore, key string)

StoreType stores a content type built from the key.

func StoredCategory

func StoredCategory(t *testing.T, store content.Store, title string, author uuid.UUID) content.Content

StoredCategory stores one category item and returns it.

func TitleIn

func TitleIn(t *testing.T, types content.TypeStore, groupID int) content.Field

TitleIn stores a text field keyed title at the top of the group and returns it.

func TitlesOf

func TitlesOf(posts []content.ListedItem) []string

TitlesOf returns the titles of the listed items in order.

func Trash

func Trash(t *testing.T, store content.Store, item content.Content)

Trash sends a stored item to the trash.

func TypedHolding

func TypedHolding(
	t *testing.T, types content.TypeStore, store content.Store, typeKey, title string, author uuid.UUID,
	values content.Values,
) (content.Content, content.Revision)

TypedHolding stores an item of the type holding the values with a revision holding them too, and returns both.

func ValuesOf

func ValuesOf(t *testing.T, store content.Store, id uuid.UUID) content.Values

ValuesOf returns the field values the store holds for the item.

Types

type Case

type Case struct {
	Name string
	Run  func(t *testing.T, s Stores)
}

Case is one named behaviour every store of its kind shares.

func Cases

func Cases() []Case

Cases returns every content store case in a fixed order.

func SiteSettingCases

func SiteSettingCases() []Case

SiteSettingCases returns every site setting store case in a fixed order.

func TypeCases

func TypeCases() []Case

TypeCases returns every type store case in a fixed order.

func UserSettingCases

func UserSettingCases() []Case

UserSettingCases returns every user setting store case in a fixed order.

type Factory

type Factory func(t *testing.T) Stores

Factory returns fresh stores for one case, skipping the case when its engine is out of reach.

type Stores

type Stores struct {
	Content      content.Store
	Types        content.TypeStore
	SiteSettings content.SiteSettingStore
	UserSettings content.UserSettingStore
	AddAuthor    func(t *testing.T, name string) uuid.UUID
}

Stores is one fresh set of content, type, site setting and user setting stores, holding only the built-in post type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL