fixtures

package
v0.24.3 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RedisOpRpush = "RPUSH"
	RedisOpSet   = "SET"
)

Variables

This section is empty.

Functions

func GetValueId

func GetValueId(value any) (any, bool)

func KernelMiddlewareLoader

func KernelMiddlewareLoader(factory FixtureSetsFactory) kernel.MiddlewareFactory

func NewBlobPurger added in v0.24.0

func NewBlobPurger(ctx context.Context, config cfg.Config, logger log.Logger, settings *BlobFixturesSettings) (*blobPurger, error)

func NewDynamodbPurger added in v0.24.0

func NewDynamodbPurger(ctx context.Context, config cfg.Config, logger log.Logger, settings *ddb.Settings) (*dynamodbPurger, error)

func NewMysqlPurger added in v0.24.0

func NewMysqlPurger(ctx context.Context, config cfg.Config, logger log.Logger, tableName string) (*mysqlPurger, error)

func NewRedisPurger added in v0.24.0

func NewRedisPurger(ctx context.Context, config cfg.Config, logger log.Logger, name string) (*redisPurger, error)

Types

type AutoNumbered

type AutoNumbered struct {
	// contains filtered or unexported fields
}

func NewAutoNumbered

func NewAutoNumbered() *AutoNumbered

func NewAutoNumberedFrom

func NewAutoNumberedFrom(initial uint) *AutoNumbered

func (*AutoNumbered) GetNext

func (n *AutoNumbered) GetNext() *uint

GetNext provides a fresh id for a fixture in case you don't want to assign specific ids Keep in mind that the ids are unique only in the scope of the same *AutoNumbered instance

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 BlobFixturesSettings struct {
	BasePath   string
	ConfigName string
}

type DdbWriterOption

type DdbWriterOption func(settings *ddb.Settings)

func WithDdbModelIdApplication

func WithDdbModelIdApplication(application string) DdbWriterOption

type FixtureLoader

type FixtureLoader interface {
	Load(ctx context.Context, fixtureSets []FixtureSet) error
}

func NewFixtureLoader

func NewFixtureLoader(ctx context.Context, config cfg.Config, logger log.Logger) FixtureLoader

type FixtureSet

type FixtureSet interface {
	Write(ctx context.Context) error
}

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

type FixtureSetSettings struct {
	Enabled bool
	Purge   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) ([]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 NewConfigurableKvStoreFixtureWriter[T any](ctx context.Context, config cfg.Config, logger log.Logger, name string) (FixtureWriter, error)

func NewConfigurableKvStoreFixtureWriterWithInterfaces

func NewConfigurableKvStoreFixtureWriterWithInterfaces[T any](logger log.Logger, store kvstore.KvStore[T]) FixtureWriter

func NewDynamoDbFixtureWriter added in v0.24.0

func NewDynamoDbFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, settings *ddb.Settings, options ...DdbWriterOption) (FixtureWriter, error)

func NewDynamoDbFixtureWriterWithInterfaces

func NewDynamoDbFixtureWriterWithInterfaces(logger log.Logger, factory ddbRepoFactory, purger *dynamodbPurger) FixtureWriter

func NewDynamoDbKvStoreFixtureWriter added in v0.24.0

func NewDynamoDbKvStoreFixtureWriter[T any](ctx context.Context, config cfg.Config, logger log.Logger, modelId *mdl.ModelId) (FixtureWriter, error)

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 NewMysqlOrmFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, metadata *db_repo.Metadata) (FixtureWriter, error)

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 NewRedisFixtureWriter(ctx context.Context, config cfg.Config, logger log.Logger, name string, operation string) (FixtureWriter, error)

func NewRedisFixtureWriterWithInterfaces

func NewRedisFixtureWriterWithInterfaces(logger log.Logger, client redis.Client, purger *redisPurger, operation string) FixtureWriter

func NewRedisKvStoreFixtureWriter added in v0.24.0

func NewRedisKvStoreFixtureWriter[T any](ctx context.Context, config cfg.Config, logger log.Logger, modelId *mdl.ModelId) (FixtureWriter, error)

func NewRedisKvStoreFixtureWriterWithInterfaces

func NewRedisKvStoreFixtureWriterWithInterfaces[T any](logger log.Logger, store kvstore.KvStore[T], purger *redisPurger) FixtureWriter

type KvStoreFixture

type KvStoreFixture struct {
	Key   interface{}
	Value interface{}
}

type MysqlPlainFixtureValues

type MysqlPlainFixtureValues []interface{}

type MysqlPlainMetaData

type MysqlPlainMetaData struct {
	TableName string
	Columns   []string
}

type MysqlSqlxMetaData added in v0.21.5

type MysqlSqlxMetaData struct {
	TableName string
}

type NamedFixture

type NamedFixture[T any] struct {
	Name  string
	Value T
}

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 Purger added in v0.24.0

type Purger interface {
	Purge(ctx context.Context) error
}

type RedisFixture

type RedisFixture struct {
	Key    string
	Value  interface{}
	Expiry time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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