Documentation ¶
Overview ¶
Package ttgenlib is a framework to create table tests generators with ease.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run( appName string, mockLookup MockLookup, logging GenLoggingRenderer, genOpts ...GenOption, ) error
Run table tests generation with a given names and handlers.
Types ¶
type GenLoggingRenderer ¶ added in v0.0.2
type GenLoggingRenderer = generator.LoggingRenderer
GenLoggingRenderer renders error messages. These variables:
t *testing.T err error
are available in the generation scope to use.
type GenOption ¶ added in v0.0.2
GenOption code generation option type.
func GenCtxInit ¶ added in v0.0.2
func GenCtxInit(ctxinit GenUserDefinedCodeRenderer) GenOption
GenCtxInit overrides default context.Context initialization code rendering.
func GenMockContext ¶ added in v0.0.2
func GenMockContext() GenOption
GenMockContext enables mocking for context.Context parameter or field.
func GenMockerNames ¶ added in v0.0.2
GenMockerNames this option is used to override default mocker file and type name generation. It is <type_name>_mocker_test.go and <typeName>Mocker by default.
func GenNoMock ¶ added in v0.0.2
GenNoMock adds an interface tye that does not need to be mocked. context.Context is one by default. Use GenMockContext to override this.
func GenPreTest ¶ added in v0.0.2
func GenPreTest(pretest GenUserDefinedCodeRenderer) GenOption
GenPreTest is a generator which can be used to put some additional code just after ctrl := ... part and right before everything else in the test logic.
type GenUserDefinedCodeRenderer ¶ added in v0.0.2
type GenUserDefinedCodeRenderer = func(r *gogh.GoRenderer[*gogh.Imports])
GenUserDefinedCodeRenderer just a shortcut for hard to read function type defintion.
type MockLookup ¶ added in v0.0.2
type MockLookup = generator.MockLookup
MockLookup a (functional) type to look for mocks for a given type.
func StandardMockLookup ¶ added in v0.0.2
func StandardMockLookup(altPaths []string, template string, custom map[string]string) MockLookup
StandardMockLookup this is a mock lookup function that is seemingly sufficient for Google's mockgen and pamgen mock generators.
- altPaths is a list of package paths to look in if no mock was found in object's own package.
- template is a template for mock type name based on the type name. Will look be "Mock${type}" for mockgen and "${type|P}Mock" for pamgen. P is the formatting option to translate original type name into the public one, `pamgen` always translates mock names into public form.
- custom map can specify mock type names for certain types.
It looks for a mock type in the given type's package first, then move to altPaths provided if no match was found. These criteria must be satisfied:
- The mock type name must be equal to template with type name applied to it.
- The mock type must implement the given type (it is an interface).
- There should be a function NewXXX(*gomock.Controller) *XXX in the package, where XXX is a mock type name.
type MockLookupResult ¶ added in v0.0.2
type MockLookupResult = generator.MockLookupResult
MockLookupResult a result to be returned when a mock for a given type was found.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
extmocks
Package extmocks mocks for outer interfaces are here.
|
Package extmocks mocks for outer interfaces are here. |
generator
Package generator deals with code generation.
|
Package generator deals with code generation. |
ordmap
Package ordmap implements ordered map.
|
Package ordmap implements ordered map. |
predictor
Package predictor to define command line predictions.
|
Package predictor to define command line predictions. |