1
0
Fork 0
mirror of https://github.com/jimeh/go-golden.git synced 2025-12-21 21:36:40 +00:00
No description
Find a file
jimehbot[bot] e17b04717f
chore(main): release 0.2.1 (#15)
Co-authored-by: jimehbot[bot] <132453784+jimehbot[bot]@users.noreply.github.com>
2025-04-05 12:34:00 +01:00
.github chore(main): release 0.2.1 (#15) 2025-04-05 12:34:00 +01:00
testdata refactor(golden): major refactor and improvements 2021-09-17 02:21:32 +01:00
.gitignore refactor(golden): major refactor and improvements 2021-09-17 02:21:32 +01:00
.golangci.yml ci(deps): update actions and lint config to get them all running again (#5) 2025-03-22 01:23:12 +00:00
CHANGELOG.md chore(main): release 0.2.1 (#15) 2025-04-05 12:34:00 +01:00
example_test.go feat(do): add new Do function to simplify golden usage (#11) 2025-03-24 13:17:17 +00:00
go.mod feat(go)!: upgrade to Go 1.17 (from 1.15) (#6) 2025-03-22 01:37:06 +00:00
go.sum feat(go)!: upgrade to Go 1.17 (from 1.15) (#6) 2025-03-22 01:37:06 +00:00
golden.go feat(options): add optional Options arguments to New() function (#14) 2025-04-05 12:28:57 +01:00
golden_test.go feat(options): add optional Options arguments to New() function (#14) 2025-04-05 12:28:57 +01:00
LICENSE feat(golden): initial commit 2021-09-16 02:46:51 +01:00
Makefile feat(do): add new Do function to simplify golden usage (#11) 2025-03-24 13:17:17 +00:00
options.go feat(options): add optional Options arguments to New() function (#14) 2025-04-05 12:28:57 +01:00
options_test.go feat(options): add optional Options arguments to New() function (#14) 2025-04-05 12:28:57 +01:00
README.md feat(do): add new Do function to simplify golden usage (#11) 2025-03-24 13:17:17 +00:00
sanitize.go refactor(golden): major refactor and improvements 2021-09-17 02:21:32 +01:00
sanitize_test.go refactor(golden): major refactor and improvements 2021-09-17 02:21:32 +01:00
testing_t.go feat(interface): use TestingT interface intead of *testing.T in function signatures (#13) 2025-03-24 13:04:34 +00:00
update.go feat(update): make default GOLDEN_UPDATE env var check case-insensitive (#10) 2025-03-24 12:53:34 +00:00
update_test.go feat(update): make default GOLDEN_UPDATE env var check case-insensitive (#10) 2025-03-24 12:53:34 +00:00

go-golden

Yet another Go package for working with *.golden test files, with a focus on simplicity.

Go Reference Actions Status Coverage GitHub issues GitHub pull requests License Status

Import

import "github.com/jimeh/go-golden"

Usage

func TestExampleMyStruct(t *testing.T) {
    got, err := json.Marshal(&MyStruct{Foo: "Bar"})
    require.NoError(t, err)

    want := golden.Do(t, got)

    assert.Equal(t, want, got)
}

The above example will read/write to:

  • testdata/TestExampleMyStruct.golden

The call to golden.Do() is equivalent to:

if golden.Update() {
    golden.Set(t, got)
}
want := golden.Get(t)

To update the golden file (have golden.Update() return true), simply set the GOLDEN_UPDATE environment variable to one of 1, y, t, yes, on, or true when running tests.

Documentation

Please see the Go Reference for documentation and examples.

License

MIT