Documentation ¶
Overview ¶
Package fixturetest allows generating values using a possibly-random source on the first run of a test, and stores it in a file for subsequent runs.
Usage ¶
In your test, add a flag or other means of requesting the update mode:
var _update = flag.Bool("update", false, "update golden files")
Configure the fixtures with the update flag:
var _fixtures = fixturetest.Config{Update: _update}
Set up one or more fixtures:
branchNameFixture := fixturetest.New(_fixtures, "branchName", func() string { return randomBranchName() })
Generate or fetch values using the Get method:
branchNameFixture.Get(t)
If the test is in update mode, the provided function will be called, and the value persisted to disk. Otherwise, the value will be read from disk and passed to the function.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Update is a pointer to a value speciftying // whether we're in update mode or read mode. // // This must not be nil. Update *bool // required }
Config configures the behavior of the fixture system.
Click to show internal directories.
Click to hide internal directories.