Documentation ¶
Overview ¶
Package goldie provides test assertions based on golden files. It's typically used for testing responses with larger data bodies.
The concept is straight forward. Valid response data is stored in a "golden file". The actual response data will be byte compared with the golden file and the test will fail if there is a difference.
Updating the golden file can be done by running `go test -update ./...`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // FixtureDir is the folder name for where the fixtures are stored. It's // relative to the "go test" path. FixtureDir = "fixtures" // FileNameSuffix is the suffix appended to the fixtures. Set to empty // string to disable file name suffixes. FileNameSuffix = ".golden" // FlagName is the name of the command line flag for go test. FlagName = "update" // FilePerms is used to set the permissions on the golden fixture files. FilePerms os.FileMode = 0644 // DirPerms is used to set the permissions on the golden fixture folder. DirPerms os.FileMode = 0755 )
Functions ¶
func Assert ¶
Assert compares the actual data received with the expected data in the golden files. If the update flag is set, it will also update the golden file.
`name` refers to the name of the test and it should typically be unique within the package. Also it should be a valid file name (so keeping to `a-z0-9\-\_` is a good idea).
func AssertJson ¶
AssertJson compares the actual json data received with expected data in the golden files. If the update flag is set, it will also update the golden file.
`name` refers to the name of the test and it should typically be unique within the package. Also it should be a valid file name (so keeping to `a-z0-9\-\_` is a good idea).
func AssertWithTemplate ¶
Assert compares the actual data received with the expected data in the golden files after executing it as a template with data parameter. If the update flag is set, it will also update the golden file. `name` refers to the name of the test and it should typically be unique within the package. Also it should be a valid file name (so keeping to `a-z0-9\-\_` is a good idea).
Types ¶
This section is empty.