Documentation ¶
Index ¶
Constants ¶
const ( NewFile string = "(new file)" NoChange string = "(no change)" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Test ¶
type Test struct { Name string Directory string Specification TestSpecification }
Test defines a single equivalence test within our framework.
Each test has a Name that references the directory that contains our testing data. Within this directory there should be a `spec.json` file which is read in the TestSpecification object.
The Directory variable references the parent directory of the test, so the full path for a given test case is paths.Join(test.Directory, test.Name).
func ReadFrom ¶
func ReadFrom(directory string, globalRewrites map[string]map[string]string, filters ...string) ([]Test, error)
ReadFrom accepts a directory and returns the set of test cases specified within this directory.
func (Test) RunWith ¶
func (test Test) RunWith(tf binary.Binary) (TestOutput, error)
RunWith executes the specified test using the binary specified by the binary.Binary argument.
This function will return a TestOutput struct, which contains the file names of the outputs that we want to compare. These files are already read in and parsed in JSON objects.
type TestOutput ¶
type TestOutput struct { Test Test // contains filtered or unexported fields }
TestOutput maps a Test case to a parsed set of JSON objects.
The Files function will return these JSON objects, pre-stripped of any unwanted JSON fields.
func (TestOutput) ComputeDiff ¶
func (output TestOutput) ComputeDiff(goldens string) (map[string]string, error)
ComputeDiff will report the difference between this TestOutput and the output already stored in the golden directory specified by the parameter.
func (TestOutput) Files ¶
func (output TestOutput) Files() (map[string]*files.File, error)
Files returns the JSON files that were returned by the test stripped of any unwanted fields.
func (TestOutput) UpdateGoldenFiles ¶
func (output TestOutput) UpdateGoldenFiles(target string) error
UpdateGoldenFiles will write out the files for a given TestOutput into a target directory. This will overwrite any files already in the target directory.
type TestSpecification ¶
type TestSpecification struct { IncludeFiles []string `json:"include_files"` IgnoreFields map[string][]string `json:"ignore_fields"` Rewrites map[string]map[string]string `json:"rewrites"` // If Commands is empty, then we will execute a default set of commands: // [init, plan, apply, show, show plan]. Otherwise, these are the set of // commands that should be executed by the equivalence test framework for // this test case. Commands []binary.Command `json:"commands"` }
TestSpecification is a struct that provides the specification for a given test case.
Each test has a set of additional files that should be included in the golden file update and diff functions, these are specified in the IncludeFiles field.
Each test also has a set of JSON fields for each file that should be ignored when updating or diffing, these are specified in the IgnoreFields field.
func (*TestSpecification) AddRewrites ¶
func (s *TestSpecification) AddRewrites(rewrites map[string]map[string]string)