Documentation
¶
Overview ¶
Package behaviortest runs a behavior's examples and refusals against a fake host, so a behavior's provider is tested from its definition. A behavior's own test calls Run; osapi dsl behavior create writes that line.
Index ¶
Constants ¶
const Hostname = "test-host"
Hostname is the fake host's name.
Variables ¶
Now is the fake host's time, for each example: an output that reads the clock, such as an uptime, is computed from it.
Functions ¶
func ChainProblems ¶
ChainProblems are the problems of the chain rules that need a run of the examples of b: a call to a behavior that the caller does not require, a call that gives a secret to a field that is not a secret.Value, and a requirement of b that no example calls. osapi dsl chain validate reports them, and Run fails the tests of b on them.
func Check ¶
Check runs every example of every method of b on a fake host, once per platform b declares, with that platform's provider, and returns what went wrong. For each example:
- the output is the example's Output;
- each declared effect holds: a file written or removed, a command run;
- a write that reports changed declares at least one effect;
- a write run a second time reports changed: false;
- with each filesystem, command and store call failing in turn, and with each store read returning a damaged record in turn, the method returns rather than panics.
For each refusal declared with Fails, the call fails with an error that contains its text. And each string input field is probed with hostile values, as checkProbes describes.
func ReadsThroughRunCmd ¶
ReadsThroughRunCmd makes m answer each RunReadCmd, the read that gohai runs, with m's own RunCmd: a test of a provider then states each command once, as RunCmd, whether gohai or the provider runs it.
Types ¶
type ChainRun ¶
type ChainRun struct {
Method string `json:"method"`
Example string `json:"example"`
Platform behavior.PlatformName `json:"platform"`
Root *behavior.Step `json:"root"`
}
ChainRun is one example of a method, run on a fake host, with each Call that it made: the root step is the method, and its steps are the calls.