factory

package
v0.1.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Package factory is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	TagName = "factory"
)

Functions

This section is empty.

Types

type Args

type Args interface {
	Instance() any
	Parent() Args
	Context() context.Context
	// contains filtered or unexported methods
}

type Factory

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

func NewFactory

func NewFactory(model any) *Factory

NewFactory returns a new factory for specified model class Each generator is applied in the order in which they are declared

func (*Factory) Attr

func (fa *Factory) Attr(name string, gen Generator, formatters ...Formatter) *Factory

func (*Factory) Clean

func (fa *Factory) Clean()

Remove all temporary files if existed

func (*Factory) Construct

func (fa *Factory) Construct(ptr any) error

Bind values of a new objects to a pointer to struct.

ptr: a pointer to struct

func (*Factory) ConstructWithContextAndOption

func (fa *Factory) ConstructWithContextAndOption(ctx context.Context, ptr any, opt map[string]any) error

Bind values of a new objects to a pointer to struct with context and option.

ctx: context object ptr: a pointer to struct opt: attibute values

func (*Factory) ConstructWithOption

func (fa *Factory) ConstructWithOption(ptr any, opt map[string]any) error

Bind values of a new objects to a pointer to struct with option.

ptr: a pointer to struct opt: attibute values

func (*Factory) Create

func (fa *Factory) Create() (any, error)

func (*Factory) CreateWithContext

func (fa *Factory) CreateWithContext(ctx context.Context) (any, error)

func (*Factory) CreateWithContextAndOption

func (fa *Factory) CreateWithContextAndOption(ctx context.Context, opt map[string]any) (any, error)

func (*Factory) CreateWithOption

func (fa *Factory) CreateWithOption(opt map[string]any) (any, error)

func (*Factory) CreateX

func (fa *Factory) CreateX() any

func (*Factory) CreateXWithContextAndOption

func (fa *Factory) CreateXWithContextAndOption(ctx context.Context, opt map[string]any) any

func (*Factory) CreateXWithOption

func (fa *Factory) CreateXWithOption(opt map[string]any) any

func (*Factory) File

func (fa *Factory) File(name, ext string, gen func(*os.File) (any, error), formatters ...Formatter) *Factory

Default directory containing temporary files is "dir" directory at the same level of directory executing commands. ext is extension eg "txt", "bat", "xlsx", etc

func (*Factory) FileWithDir

func (fa *Factory) FileWithDir(name, ext, dir string, gen func(*os.File) (any, error), formatters ...Formatter) *Factory

You should call Clean function in defer after invoking FileWithDir function (See Clean) to clean all unused files. Otherwise, files will not be removed

func (*Factory) Jpg

func (fa *Factory) Jpg(name string, gen func(*os.File) (any, error), formatters ...Formatter) *Factory

Jpg function is a shortcut for creating jpg files. No file name is required. For specifying file name, see File function

func (*Factory) MustCreate

func (fa *Factory) MustCreate() any

MustCreate will be deprecated in future releases. Please use CreateX instead.

func (*Factory) MustCreateWithContextAndOption

func (fa *Factory) MustCreateWithContextAndOption(ctx context.Context, opt map[string]any) any

MustCreateWithContextAndOption will be deprecated in future releases. Please use CreateXWithContextAndOption instead.

func (*Factory) MustCreateWithOption

func (fa *Factory) MustCreateWithOption(opt map[string]any) any

MustCreateWithOption will be deprecated in future releases. Please use CreateXWithOption instead.

func (*Factory) OnCreate

func (fa *Factory) OnCreate(cb func(Args) error) *Factory

OnCreate registers a callback on object creation. If callback function returns error, object creation is failed.

func (*Factory) Png

func (fa *Factory) Png(name string, gen func(*os.File) (any, error), formatters ...Formatter) *Factory

Png function is a shortcut for creating png files. No file name is required. For specifying file name, see File function

func (*Factory) SeqInt

func (fa *Factory) SeqInt(name string, gen func(int) (any, error), formatters ...Formatter) *Factory

func (*Factory) SeqInt64

func (fa *Factory) SeqInt64(name string, gen func(int64) (any, error), formatters ...Formatter) *Factory

func (*Factory) SeqString

func (fa *Factory) SeqString(name string, gen func(string) (any, error), formatters ...Formatter) *Factory

func (*Factory) SubFactory

func (fa *Factory) SubFactory(name string, sub *Factory, formatters ...Formatter) *Factory

func (*Factory) SubRecursiveFactory

func (fa *Factory) SubRecursiveFactory(name string, sub *Factory, getLimit func() int, formatters ...Formatter) *Factory

func (*Factory) SubRecursiveSliceFactory

func (fa *Factory) SubRecursiveSliceFactory(name string, sub *Factory, getSize, getLimit func() int, formatters ...Formatter) *Factory

func (*Factory) SubSliceFactory

func (fa *Factory) SubSliceFactory(name string, sub *Factory, getSize func() int, formatters ...Formatter) *Factory

type Formatter

type Formatter func(any) (any, error)

type Generator

type Generator func(Args) (any, error)

type MockArgs

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

MockArgs is a mock of Args interface.

func NewMockArgs

func NewMockArgs(ctrl *gomock.Controller) *MockArgs

NewMockArgs creates a new mock instance.

func (*MockArgs) Context

func (m *MockArgs) Context() context.Context

Context mocks base method.

func (*MockArgs) EXPECT

func (m *MockArgs) EXPECT() *MockArgsMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockArgs) Instance

func (m *MockArgs) Instance() any

Instance mocks base method.

func (*MockArgs) Parent

func (m *MockArgs) Parent() Args

Parent mocks base method.

type MockArgsMockRecorder

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

MockArgsMockRecorder is the mock recorder for MockArgs.

func (*MockArgsMockRecorder) Context

func (mr *MockArgsMockRecorder) Context() *gomock.Call

Context indicates an expected call of Context.

func (*MockArgsMockRecorder) Instance

func (mr *MockArgsMockRecorder) Instance() *gomock.Call

Instance indicates an expected call of Instance.

func (*MockArgsMockRecorder) Parent

func (mr *MockArgsMockRecorder) Parent() *gomock.Call

Parent indicates an expected call of Parent.

type Stacks

type Stacks []*int64

func (*Stacks) Has

func (st *Stacks) Has(idx int) bool

func (*Stacks) Next

func (st *Stacks) Next(idx int) bool

func (*Stacks) Pop

func (st *Stacks) Pop(idx, delta int)

func (*Stacks) Push

func (st *Stacks) Push(idx, delta int)

func (*Stacks) Set

func (st *Stacks) Set(idx, val int)

Set method is not goroutine safe.

func (*Stacks) Size

func (st *Stacks) Size(idx int) int64

Jump to

Keyboard shortcuts

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