module spec.tf
The tweakstreet/spec
module contains libraries useful for creating test suites
involving tweakstreet flows.
library effects
Contains effects useful for before hooks, after hooks, and subject definition.
flow
(
string file,
dict parameters,
function callback,
boolean inherit_globals=true,
boolean log_to_console=false,
string log_file,
string log_level="INFO",
list globals,
any context
) -> dict
Creates an effect node that runs a flow when invoked.
The effect fails if the flow fails.
The result of the effect is the flow result after completion.
Parameter | Description |
---|---|
file | the flow to run |
parameters | dict of parameters to pass to the flow |
callback | if a function is given, the result of the effect is callback(flow_result) |
inherit_globals | if true, all global modules passed to the spec runner are also included during flow execution, useful to pass through environment configuration |
log_to_console | if true, log output is forwarded to console as usual, if false there is no log output to the console |
log_file | if specified, the log output is written to this file |
globals | list of paths to global modules to be included during flow execution |
context | arbitrary data potentially useful in reporters |
If file or log_file are relative, they are resolved as relative to the spec module calling the function.
try_flow
(
string file,
dict parameters,
function callback,
boolean inherit_globals=true,
boolean log_to_console=false,
string log_file,
string log_level="INFO",
list globals,
any context
) -> dict
Creates an effect node that runs a flow when invoked.
The result of the effect is a dict of the following shape:
{
:success boolean indicator of success
:error error value in case of flow failure, nil in case of success
:result result value in case of flow success, nil in case of failure
}
Parameter | Description |
---|---|
file | the flow to run |
parameters | dict of parameters to pass to the flow |
callback | if a function is given, the result of the effect is callback(flow_result) |
inherit_globals | if true, all global modules passed to the spec runner are also included during flow execution, useful to pass through environment configuration |
log_to_console | if true, log output is forwarded to console as usual, if false there is no log output to the console |
log_file | if specified, the log output is written to this file |
globals | list of paths to global modules to be included during flow execution |
context | arbitrary data potentially useful in reporters |
If file or log_file are relative, they are resolved as relative to the spec module calling the function.
find
(
string glob,
string dir=".",
function callback,
any context
) -> dict
Returns an effect node that searches the file system for files matching a glob pattern when invoked.
The return value of the effect is a list of found paths.
Parameter | Description |
---|---|
glob | the glob or regular expression to match files |
dir | the directory to search in |
callback | if a function is given, the result of the effect is callback(found_paths) |
context | arbitrary data potentially useful in reporters |
If given dir is relative, it is resolved as relative to the spec module calling the function.
file
(
string path,
function callback,
any context
) -> dict
Returns an effect node that returns the binary file contents of a given file when invoked.
The return value of the effect is of type binary.
Parameter | Description |
---|---|
path | the path to read from |
callback | if a function is given, the result of the effect is callback(file_bytes) |
context | arbitrary data potentially useful in reporters |
If given path is relative, it is resolved as relative to the spec module calling the function.