Documentation ¶
Overview ¶
Package testcontext provides logic to extract information from context.
Package testcontext provides logic to extract information from context.
Index ¶
- func Log(ctx context.Context, args ...interface{})
- func Logf(ctx context.Context, format string, args ...interface{})
- func OutDir(ctx context.Context) (dir string, ok bool)
- func ServiceDeps(ctx context.Context) ([]string, bool)
- func SoftwareDeps(ctx context.Context) ([]string, bool)
- func WithCurrentEntity(ctx context.Context, ec *CurrentEntity) context.Context
- func WithLogger(ctx context.Context, logger LoggerFunc) context.Context
- type CurrentEntity
- type LoggerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OutDir ¶
OutDir is similar to testing.State.OutDir but takes context instead. It is intended to be used by packages providing support for tests that need to write files.
func ServiceDeps ¶
ServiceDeps is similar to testing.State.ServiceDeps but takes context instead. It is intended to be used by packages providing support for tests that want to make sure tests declare proper dependencies.
func SoftwareDeps ¶
SoftwareDeps is similar to testing.State.SoftwareDeps but takes context instead. It is intended to be used by packages providing support for tests that want to make sure tests declare proper dependencies.
func WithCurrentEntity ¶
func WithCurrentEntity(ctx context.Context, ec *CurrentEntity) context.Context
WithCurrentEntity attaches CurrentEntity to context.Context. This function can't be called from user code.
func WithLogger ¶
func WithLogger(ctx context.Context, logger LoggerFunc) context.Context
WithLogger creates a context associated with logger. The returned context can be used to call Log/Logf.
Types ¶
type CurrentEntity ¶
type CurrentEntity struct { // OutDir is a directory where the current entity can save output files. OutDir string // HasSoftwareDeps indicates if software dependencies are available for the // current entity. It is true only for tests. HasSoftwareDeps bool // SoftwareDeps is a list of software dependencies declared in the current entity. SoftwareDeps []string // ServiceDeps is a list of service dependencies declared in the current entity. ServiceDeps []string }
CurrentEntity contains information about the currently running entity.
Information in this struct is accessible from anywhere via context.Context and testing.Context* functions. Each member should have strong reason to be accessible without testing.*State.
type LoggerFunc ¶
type LoggerFunc = func(msg string)
LoggerFunc is the type of a function to emit log messages.