Documentation ¶
Overview ¶
Package testcontext provides logic to extract information from context.
Package testcontext provides logic to extract information from context.
Index ¶
- func EnsurePrivateAttr(ctx context.Context, name string)
- func OutDir(ctx context.Context) (dir string, ok bool)
- func PrivateAttr(ctx context.Context) (privateAttr []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 WithPrivateData(ctx context.Context, pd PrivateData) context.Context
- type CurrentEntity
- type PrivateData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsurePrivateAttr ¶
EnsurePrivateAttr ensures the current entity declares a privateAttr in its metadata. Otherwise it will panic.
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 PrivateAttr ¶
PrivateAttr returns the private attributes of current entity.
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 WithPrivateData ¶
func WithPrivateData(ctx context.Context, pd PrivateData) context.Context
WithPrivateData attaches PrivateData to context.Context. This function must not be exposed to user code.
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. // TODO(b/229939530): Will add support for multi-DUT dependency in future. SoftwareDeps []string // ServiceDeps is a list of service dependencies declared in the current entity. ServiceDeps []string // PrivateAttr is a list of private attributes declared in the current entity. PrivateAttr []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 PrivateData ¶
type PrivateData struct { // WaitUntilReady carries the value of -waituntilready flag. WaitUntilReady bool // WaitUntilReadyTimeout carries the value of -waituntilreadytimeout flag. WaitUntilReadyTimeout time.Duration }
PrivateData contains information private to the framework.
func PrivateDataFromContext ¶
func PrivateDataFromContext(ctx context.Context) (pd PrivateData, ok bool)
PrivateDataFromContext extracts PrivateData from a context.Context. This function must not be exposed to user code.