https://github.com/eberkund/rose
Rose is a golden file utility library for your Go tests.
https://github.com/eberkund/rose
fixtures go golden testing
Last synced: 5 months ago
JSON representation
Rose is a golden file utility library for your Go tests.
- Host: GitHub
- URL: https://github.com/eberkund/rose
- Owner: eberkund
- License: mit
- Created: 2022-05-07T08:14:39.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-09T04:16:18.000Z (over 3 years ago)
- Last Synced: 2024-06-21T01:37:25.021Z (about 2 years ago)
- Topics: fixtures, go, golden, testing
- Language: Go
- Homepage:
- Size: 63.5 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/eberkund/rose/actions/workflows/tests.yml)
[](https://codecov.io/gh/eberkund/rose)
[](https://goreportcard.com/report/github.com/eberkund/rose)
[](https://godoc.org/github.com/eberkund/rose)
# Rose
Rose is a golden file utility library for your Go tests.
It handles the dirty work so your tests stay concise and readable.
- Normalizes common file formats
- Helps organize files with per-test path prefixes
- Leaves you in control of supplying the update flag
## Usage
```go
package mypackage
import (
"flag"
"testing"
"github.com/eberkund/rose/gold"
)
// Use `go test ./... -update` to write new files with supplied data
var update = flag.Bool("update", false, "update golden files")
func TestFiles(t *testing.T) {
g := gold.New(
t,
// Pass the update flag to Gold constructor
gold.WithFlag(*update),
// Store files in `testdata//`
// Prefix defaults to `testdata`
gold.WithPrefix("testdata", t.Name()),
)
// Provide the filename and input data
g.AssertEqualsJSON("somefile.golden.json", `{"foo": 123}`)
}
```