Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Binary ¶
type Binary interface {
// ExecuteTest executes a series of commands in order and returns the
// output of the apply and plan steps, the state, and any additionally
// requested files.
ExecuteTest(directory string, includeFiles []string, commands ...Command) (map[string]*files.File, error)
// Version returns the version of the underlying binary.
Version() string
}
Binary is an interface that can execute a single equivalence test within a directory using the ExecuteTest method.
We hold this in an interface, so we can mock it for testing purposes.
type Command ¶
type Command struct {
// The Name of the command to execute. This field is used for logging when
// reporting which command might have failed.
Name string `json:"name"`
// A list of Arguments to pass to the binary, eg. `init`, `plan`,
// `show -json`, etc.
Arguments []string `json:"arguments"`
// CaptureOutput should be set to true if we want to record the output of
// this command and compare/copy it into the golden files.
CaptureOutput bool `json:"capture_output"`
// OutputFileName is the name of the file that the framework should write
// the captured output into.
//
// This field is ignored if CaptureOutput is false.
OutputFileName string `json:"output_file_name"`
// HasJsonOutput tells the framework the output is going to be in JSON
// format.
//
// This means that `IgnoreFields` section of the test specification can be
// applied to the output of this command. It also provides a better diffing
// output as JSON is easier to diff and display than raw strings.
//
// This field is ignored if CaptureOutput is false.
HasJsonOutput bool `json:"has_json_output"`
// StreamsJsonOutput tells the framework the output isn't going to arrive in
// pure JSON but as a list of structured JSON statements. In this case the
// framework will strip out any `\n` characters, put the output inside a
// JSON list: `[`, `]`, and finally append the statements together with a
// `,` character.
//
// This command basically turns the structured output into a JSON list that
// can be handled by the rest of the framework. An example of this is the
// output of an apply command: `$binary apply -json`.
//
// This field is ignored if CaptureOutput is false or if HasJsonOutput is
// false.
StreamsJsonOutput bool `json:"streams_json_output"`
}
Command is a struct that instructs the framework how to execute a custom command. It covers the arguments that should be passed to the binary, and instructs whether the output should be captured and how it should be captured.
Click to show internal directories.
Click to hide internal directories.