Skip to content
Go module for reading and writing golden files in testdata/
Go Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
testdata
.gitignore
.travis.yml
LICENSE
README.md
changelog.md
example_test.go
go.mod
go.sum
onchange.sh
qa_test.go
store.go
store_test.go

README.md

Build Status codecov Maintainability

golden - package defines test helper for working with golden files

Golden files contain expected values within your tests. They are useful when you want to check more complex outputs. This package makes it easy to Save and Load such files within the testdata directory.

Simplest example

func TestMe(t *testing.T) {
    got := doSomething()
    golden.Assert(t, got)
}

The golden file for above test is saved in testdata/package.TestMe and an entry is added to testdata/golden.files which keeps track of used files. If you eg. rename a test the golden file will be saved under a new name.

Keep golden.files under revision control to quickly spot which files are no longer used.

To update the golden files use

go test -args -update-golden
You can’t perform that action at this time.