Documentation
¶
Index ¶
- func AddFixtureSetFactory(ctx context.Context, group string, factory FixtureSetsFactory) error
- func AddFixtureSetPostProcessorFactory(ctx context.Context, factories ...PostProcessorFactory) error
- func GetValueId(value any) (any, bool)
- type AutoNumbereddeprecated
- type ByteSequence
- type Container
- type FixtureLoader
- type FixtureSet
- type FixtureSetFactory
- type FixtureSetOption
- type FixtureSetSettings
- type FixtureSetsFactory
- type FixtureWriter
- type NamedFixture
- type NamedFixtures
- func (l NamedFixtures[T]) All() []any
- func (l NamedFixtures[T]) CountIf(f func(elem T) bool) int
- func (l NamedFixtures[T]) FindAll(f func(elem T) bool) []T
- func (l NamedFixtures[T]) FindFirst(f func(elem T) bool) (T, bool)
- func (l NamedFixtures[T]) GetValueById(id any) T
- func (l NamedFixtures[T]) GetValueByName(name string) T
- func (l NamedFixtures[T]) Len() int
- type NumberSequence
- type PostProcessor
- type PostProcessorFactory
- type UuidSequence
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFixtureSetFactory ¶ added in v0.37.0
func AddFixtureSetFactory(ctx context.Context, group string, factory FixtureSetsFactory) error
func AddFixtureSetPostProcessorFactory ¶ added in v0.37.0
func AddFixtureSetPostProcessorFactory(ctx context.Context, factories ...PostProcessorFactory) error
func GetValueId ¶
Types ¶
type AutoNumbered
deprecated
type AutoNumbered NumberSequence
AutoNumbered is the old name for a NumberSequence
Deprecated: use NumberSequence instead
func NewAutoNumbered
deprecated
func NewAutoNumbered() AutoNumbered
NewAutoNumbered is the old name for NewNumberSequence
Deprecated: use NewNumberSequence instead
func NewAutoNumberedFrom
deprecated
func NewAutoNumberedFrom(initial uint) AutoNumbered
NewAutoNumberedFrom is the old name for NewNumberSequenceFrom
Deprecated: use NewNumberSequenceFrom instead
type ByteSequence ¶ added in v0.25.1
type ByteSequence interface { io.Reader // GetBytes returns a slice of n bytes filled with random-looking data. GetBytes(n int) []byte }
func NewByteSequence ¶ added in v0.25.1
func NewByteSequence(seed string) ByteSequence
NewByteSequence provides a way to generate random-looking values for fixtures from a given seed. A possible use case would be to provide the name of the fixture set you are creating as the seed to get distinct values from other fixture sets, but having deterministic values compared to just generating random bytes for example.
type Container ¶ added in v0.37.0
type Container struct {
// contains filtered or unexported fields
}
func ProvideContainer ¶ added in v0.37.0
func (*Container) AddFixtureSetFactory ¶ added in v0.37.0
func (c *Container) AddFixtureSetFactory(group string, factory FixtureSetsFactory)
func (*Container) AddPostProcessorFactories ¶ added in v0.37.0
func (c *Container) AddPostProcessorFactories(factory ...PostProcessorFactory)
type FixtureLoader ¶
func NewFixtureLoader ¶
func NewFixtureLoader(ctx context.Context, config cfg.Config, logger log.Logger, fixtureSets map[string][]FixtureSet, postProcessors []PostProcessor) (FixtureLoader, error)
func NewFixtureLoaderDisabled ¶ added in v0.37.0
func NewFixtureLoaderDisabled(logger log.Logger) FixtureLoader
type FixtureSet ¶
func NewSimpleFixtureSet ¶ added in v0.24.0
func NewSimpleFixtureSet[T any](fixtures NamedFixtures[T], writer FixtureWriter, options ...FixtureSetOption) FixtureSet
type FixtureSetFactory ¶ added in v0.24.0
type FixtureSetOption ¶ added in v0.24.0
type FixtureSetOption func(settings *FixtureSetSettings)
func WithEnabled ¶ added in v0.24.0
func WithEnabled(enabled bool) FixtureSetOption
type FixtureSetSettings ¶ added in v0.24.0
type FixtureSetSettings struct {
Enabled bool
}
func NewFixtureSetSettings ¶ added in v0.24.0
func NewFixtureSetSettings(options ...FixtureSetOption) *FixtureSetSettings
type FixtureSetsFactory ¶ added in v0.24.0
type FixtureSetsFactory func(ctx context.Context, config cfg.Config, logger log.Logger, group string) ([]FixtureSet, error)
func NewFixtureSetsFactory ¶ added in v0.24.0
func NewFixtureSetsFactory(factories ...FixtureSetFactory) FixtureSetsFactory
type FixtureWriter ¶
type NamedFixture ¶
func NewNamedFixture ¶ added in v0.24.2
func NewNamedFixture[T any](name string, value T) *NamedFixture[T]
type NamedFixtures ¶ added in v0.24.0
type NamedFixtures[T any] []*NamedFixture[T]
func GetNamedFixtures ¶
func GetNamedFixtures(container any) []NamedFixtures[any]
func (NamedFixtures[T]) All ¶ added in v0.24.0
func (l NamedFixtures[T]) All() []any
All specifically returns a []any instead of a []T, so the fixture loader code doesn't complain that it can't cast a []T to []any
func (NamedFixtures[T]) CountIf ¶ added in v0.24.0
func (l NamedFixtures[T]) CountIf(f func(elem T) bool) int
func (NamedFixtures[T]) FindAll ¶ added in v0.24.0
func (l NamedFixtures[T]) FindAll(f func(elem T) bool) []T
func (NamedFixtures[T]) FindFirst ¶ added in v0.24.0
func (l NamedFixtures[T]) FindFirst(f func(elem T) bool) (T, bool)
func (NamedFixtures[T]) GetValueById ¶ added in v0.24.0
func (l NamedFixtures[T]) GetValueById(id any) T
func (NamedFixtures[T]) GetValueByName ¶ added in v0.24.0
func (l NamedFixtures[T]) GetValueByName(name string) T
func (NamedFixtures[T]) Len ¶ added in v0.24.0
func (l NamedFixtures[T]) Len() int
type NumberSequence ¶ added in v0.25.1
type NumberSequence interface { // GetNextInt returns the next number in the sequence as an integer GetNextInt() int // GetNextUint returns the next number in the sequence as an unsigned integer GetNextUint() uint // GetNextId is the same as GetNextUint, but returns a pointer to the result. // The returned id can be used to get a fresh id for a fixture if you don't want to // assign specific ids. GetNextId() *uint // GetNext is the old name of GetNextId // Deprecated: use GetNextId instead GetNext() *uint }
func NewNumberSequence ¶ added in v0.25.1
func NewNumberSequence() NumberSequence
func NewNumberSequenceFrom ¶ added in v0.25.1
func NewNumberSequenceFrom(initial uint) NumberSequence
type PostProcessor ¶ added in v0.36.0
type PostProcessorFactory ¶ added in v0.36.0
type UuidSequence ¶ added in v0.25.1
func NewUuidSequence ¶ added in v0.25.1
func NewUuidSequence(seed string) UuidSequence
NewUuidSequence provides a way to generate random-looking UUIDs for fixtures from a given seed. Use this for fixtures instead of generating random UUIDs to create distinct keys easily while also keeping the fixtures deterministic. A unique seed is required for each fixture set to ensure there are no collisions between the generated UUIDs.