Documentation ¶
Overview ¶
Package filetest helps in verifying that content written to arbitrary io.Writers match some expected content in testdata files.
See the test TestExample for an example of how to use this package.
Index ¶
Constants ¶
const ExampleStdout = exampleWriter(0)
ExampleStdout is a dumb wrapper around os.Stdout that removes trailing spaces from each line in each io.Writer.Write call. This is useful for examples where os.Stdout output is matched against some output text in comments. However, gofmt trims trailing spaces in the go source code, which means it's impossible to match trailing spaces without trimming in a wrapper like this.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Target ¶
Target is a write target for arbitrary content sources. Before verifying that the written content is right, the filters are applied in orders on the buffered content.
type Tester ¶
type Tester struct { G *goldie.Goldie T *testing.T // Files map a file name (conventionally under testdata/) to a // target buffer and set of filters. Files map[string]*Target }
Tester is a high-level primitive for goldie.Goldie. It allows registering testdata files to verify io.Writer writes.
func (*Tester) Add ¶
Add adds a new file target to the Files map. If name already exists in the map, it is overwritten.