Documentation ¶
Index ¶
- Constants
- func GetValueId(value any) (any, bool)
- func KernelMiddlewareLoader(group string, factory FixtureSetsFactory) kernel.MiddlewareFactory
- func NewBlobPurger(ctx context.Context, config cfg.Config, logger log.Logger, ...) (*blobPurger, error)
- func NewDynamodbPurger(ctx context.Context, config cfg.Config, logger log.Logger, ...) (*dynamodbPurger, error)
- func NewMysqlPurger(ctx context.Context, config cfg.Config, logger log.Logger, tableName string) (*mysqlPurger, error)
- func NewRedisPurger(ctx context.Context, config cfg.Config, logger log.Logger, name string) (*redisPurger, error)
- type AutoNumbereddeprecated
- type BlobFixture
- type BlobFixturesSettings
- type ByteSequence
- type DdbWriterOption
- type FixtureLoader
- type FixtureSet
- type FixtureSetFactory
- func BlobFixtureSetFactory[T any](settings *BlobFixturesSettings, data NamedFixtures[T], ...) FixtureSetFactory
- func ConfigurableKvStoreFixtureSetFactory[T any](name string, data NamedFixtures[*KvStoreFixture], options ...FixtureSetOption) FixtureSetFactory
- func DynamoDbFixtureSetFactory[T any](settings *ddb.Settings, data NamedFixtures[T], options ...FixtureSetOption) FixtureSetFactory
- func DynamoDbKvStoreFixtureSetFactory[T any](modelId *mdl.ModelId, data NamedFixtures[*KvStoreFixture], ...) FixtureSetFactory
- func MysqlOrmFixtureSetFactory[T any](metadata *db_repo.Metadata, data NamedFixtures[T], options ...FixtureSetOption) FixtureSetFactory
- func MysqlPlainFixtureSetFactory[T any](metadata *MysqlPlainMetaData, data NamedFixtures[T], ...) FixtureSetFactory
- func MysqlSqlxFixtureSetFactory[T any](metadata *MysqlSqlxMetaData, data NamedFixtures[T], ...) FixtureSetFactory
- func RedisFixtureSetFactory[T any](name string, operation string, data NamedFixtures[T], ...) FixtureSetFactory
- func RedisKvStoreFixtureSetFactory[T any](modelId *mdl.ModelId, data NamedFixtures[*KvStoreFixture], ...) FixtureSetFactory
- type FixtureSetOption
- type FixtureSetSettings
- type FixtureSetsFactory
- type FixtureWriter
- func NewBlobFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, ...) (FixtureWriter, error)
- func NewBlobFixtureWriterWithInterfaces(logger log.Logger, batchRunner blob.BatchRunner, purger *blobPurger, ...) FixtureWriter
- func NewConfigurableKvStoreFixtureWriter[T any](ctx context.Context, config cfg.Config, logger log.Logger, name string) (FixtureWriter, error)
- func NewConfigurableKvStoreFixtureWriterWithInterfaces[T any](logger log.Logger, store kvstore.KvStore[T]) FixtureWriter
- func NewDynamoDbFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, ...) (FixtureWriter, error)
- func NewDynamoDbFixtureWriterWithInterfaces(logger log.Logger, factory ddbRepoFactory, purger *dynamodbPurger) FixtureWriter
- func NewDynamoDbKvStoreFixtureWriter[T any](ctx context.Context, config cfg.Config, logger log.Logger, ...) (FixtureWriter, error)
- func NewDynamoDbKvStoreFixtureWriterWithInterfaces[T any](logger log.Logger, factory ddbKvstoreFactory[T], purger *dynamodbPurger) FixtureWriter
- func NewMysqlFixtureWriterWithInterfaces(logger log.Logger, metadata *db_repo.Metadata, repo db_repo.Repository, ...) FixtureWriter
- func NewMysqlOrmFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, ...) (FixtureWriter, error)
- func NewMysqlPlainFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, ...) (FixtureWriter, error)
- func NewMysqlPlainFixtureWriterWithInterfaces(logger log.Logger, client db.Client, metadata *MysqlPlainMetaData, ...) FixtureWriter
- func NewMysqlSqlxFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, ...) (FixtureWriter, error)
- func NewMysqlSqlxFixtureWriterWithInterfaces(logger log.Logger, client db.Client, metadata *MysqlSqlxMetaData, ...) FixtureWriter
- func NewRedisFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, name string, ...) (FixtureWriter, error)
- func NewRedisFixtureWriterWithInterfaces(logger log.Logger, client redis.Client, purger *redisPurger, operation string) FixtureWriter
- func NewRedisKvStoreFixtureWriter[T any](ctx context.Context, config cfg.Config, logger log.Logger, ...) (FixtureWriter, error)
- func NewRedisKvStoreFixtureWriterWithInterfaces[T any](logger log.Logger, store kvstore.KvStore[T], purger *redisPurger) FixtureWriter
- type KvStoreFixture
- type MysqlPlainFixtureValues
- type MysqlPlainMetaData
- type MysqlSqlxMetaData
- 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 Purger
- type RedisFixture
- type UuidSequence
Constants ¶
const ( RedisOpRpush = "RPUSH" RedisOpSet = "SET" )
Variables ¶
This section is empty.
Functions ¶
func GetValueId ¶
func KernelMiddlewareLoader ¶
func KernelMiddlewareLoader(group string, factory FixtureSetsFactory) kernel.MiddlewareFactory
func NewBlobPurger ¶ added in v0.24.0
func NewDynamodbPurger ¶ added in v0.24.0
func NewMysqlPurger ¶ added in v0.24.0
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 BlobFixture ¶ added in v0.24.0
type BlobFixture struct{}
BlobFixture is a dummy struct for writing nicely typed fixture sets, even though the blob fixture loader works a bit differently
type BlobFixturesSettings ¶
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 DdbWriterOption ¶
func WithDdbModelIdApplication ¶
func WithDdbModelIdApplication(application string) DdbWriterOption
type FixtureLoader ¶
type FixtureLoader interface {
Load(ctx context.Context, group string, fixtureSets []FixtureSet) error
}
func NewFixtureLoader ¶
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 FixtureSetFactory func(ctx context.Context, config cfg.Config, logger log.Logger) (FixtureSet, error)
func BlobFixtureSetFactory ¶ added in v0.24.0
func BlobFixtureSetFactory[T any](settings *BlobFixturesSettings, data NamedFixtures[T], options ...FixtureSetOption) FixtureSetFactory
func ConfigurableKvStoreFixtureSetFactory ¶ added in v0.24.0
func ConfigurableKvStoreFixtureSetFactory[T any](name string, data NamedFixtures[*KvStoreFixture], options ...FixtureSetOption) FixtureSetFactory
func DynamoDbFixtureSetFactory ¶ added in v0.24.0
func DynamoDbFixtureSetFactory[T any](settings *ddb.Settings, data NamedFixtures[T], options ...FixtureSetOption) FixtureSetFactory
func DynamoDbKvStoreFixtureSetFactory ¶ added in v0.24.0
func DynamoDbKvStoreFixtureSetFactory[T any](modelId *mdl.ModelId, data NamedFixtures[*KvStoreFixture], options ...FixtureSetOption) FixtureSetFactory
func MysqlOrmFixtureSetFactory ¶ added in v0.24.0
func MysqlOrmFixtureSetFactory[T any](metadata *db_repo.Metadata, data NamedFixtures[T], options ...FixtureSetOption) FixtureSetFactory
func MysqlPlainFixtureSetFactory ¶ added in v0.24.0
func MysqlPlainFixtureSetFactory[T any](metadata *MysqlPlainMetaData, data NamedFixtures[T], options ...FixtureSetOption) FixtureSetFactory
func MysqlSqlxFixtureSetFactory ¶ added in v0.24.0
func MysqlSqlxFixtureSetFactory[T any](metadata *MysqlSqlxMetaData, data NamedFixtures[T], options ...FixtureSetOption) FixtureSetFactory
func RedisFixtureSetFactory ¶ added in v0.24.0
func RedisFixtureSetFactory[T any](name string, operation string, data NamedFixtures[T], options ...FixtureSetOption) FixtureSetFactory
func RedisKvStoreFixtureSetFactory ¶ added in v0.24.0
func RedisKvStoreFixtureSetFactory[T any](modelId *mdl.ModelId, data NamedFixtures[*KvStoreFixture], options ...FixtureSetOption) FixtureSetFactory
type FixtureSetOption ¶ added in v0.24.0
type FixtureSetOption func(settings *FixtureSetSettings)
func WithEnabled ¶ added in v0.24.0
func WithEnabled(enabled bool) FixtureSetOption
func WithPurge ¶ added in v0.24.0
func WithPurge(purge bool) FixtureSetOption
type FixtureSetSettings ¶ added in v0.24.0
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 FixtureWriter interface { Purge(ctx context.Context) error Write(ctx context.Context, fixtures []any) error }
func NewBlobFixtureWriter ¶ added in v0.24.0
func NewBlobFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, settings *BlobFixturesSettings) (FixtureWriter, error)
func NewBlobFixtureWriterWithInterfaces ¶
func NewBlobFixtureWriterWithInterfaces(logger log.Logger, batchRunner blob.BatchRunner, purger *blobPurger, store blob.Store, basePath string) FixtureWriter
func NewConfigurableKvStoreFixtureWriter ¶ added in v0.24.0
func NewDynamoDbFixtureWriter ¶ added in v0.24.0
func NewDynamoDbFixtureWriterWithInterfaces ¶
func NewDynamoDbFixtureWriterWithInterfaces(logger log.Logger, factory ddbRepoFactory, purger *dynamodbPurger) FixtureWriter
func NewDynamoDbKvStoreFixtureWriter ¶ added in v0.24.0
func NewDynamoDbKvStoreFixtureWriterWithInterfaces ¶
func NewDynamoDbKvStoreFixtureWriterWithInterfaces[T any](logger log.Logger, factory ddbKvstoreFactory[T], purger *dynamodbPurger) FixtureWriter
func NewMysqlFixtureWriterWithInterfaces ¶
func NewMysqlFixtureWriterWithInterfaces(logger log.Logger, metadata *db_repo.Metadata, repo db_repo.Repository, purger *mysqlPurger) FixtureWriter
func NewMysqlOrmFixtureWriter ¶ added in v0.24.0
func NewMysqlPlainFixtureWriter ¶ added in v0.24.0
func NewMysqlPlainFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, metadata *MysqlPlainMetaData) (FixtureWriter, error)
func NewMysqlPlainFixtureWriterWithInterfaces ¶
func NewMysqlPlainFixtureWriterWithInterfaces(logger log.Logger, client db.Client, metadata *MysqlPlainMetaData, purger *mysqlPurger) FixtureWriter
func NewMysqlSqlxFixtureWriter ¶ added in v0.24.0
func NewMysqlSqlxFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, metadata *MysqlSqlxMetaData) (FixtureWriter, error)
func NewMysqlSqlxFixtureWriterWithInterfaces ¶ added in v0.21.5
func NewMysqlSqlxFixtureWriterWithInterfaces(logger log.Logger, client db.Client, metadata *MysqlSqlxMetaData, purger *mysqlPurger) FixtureWriter
func NewRedisFixtureWriter ¶ added in v0.24.0
func NewRedisKvStoreFixtureWriter ¶ added in v0.24.0
type KvStoreFixture ¶
type KvStoreFixture struct { Key interface{} Value interface{} }
type MysqlPlainFixtureValues ¶
type MysqlPlainFixtureValues []interface{}
type MysqlPlainMetaData ¶
type MysqlSqlxMetaData ¶ added in v0.21.5
type MysqlSqlxMetaData struct {
TableName string
}
type NamedFixture ¶
func NewNamedFixture ¶ added in v0.24.2
func NewNamedFixture[T any](name string, value T) *NamedFixture[T]
func NewNamedKvStoreFixture ¶ added in v0.24.2
func NewNamedKvStoreFixture[T any](name any, value T) *NamedFixture[*KvStoreFixture]
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 RedisFixture ¶
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.
Source Files ¶
- auto_numbered.go
- byte_sequence.go
- fixture_set_options.go
- kernel_middleware.go
- loader_noop.go
- named.go
- number_sequence.go
- purger.go
- purger_blob.go
- purger_dynamodb.go
- purger_mysql.go
- purger_redis.go
- settings.go
- simple_fixture_set.go
- types.go
- uuid_sequence.go
- writer_blob.go
- writer_configurable_kvstore.go
- writer_ddb.go
- writer_ddb_kvstore.go
- writer_ddb_options.go
- writer_mysql_orm.go
- writer_mysql_plain.go
- writer_mysql_sqlx.go
- writer_redis.go
- writer_redis_kvstore.go