GormShot adds Snapshot Testing for GORM.
Inspired by StoryShots.
go get -u github.com/nkmr-jp/gormshot
# If you want to use the latest feature.
go get -u github.com/nkmr-jp/gormshot@develop
See: gormshot_test.go
Snapshot file is saved as JSON Lines format file, so you can use jq command to show pretty output. like this.
cat .snapshot/TestAssert__value_is_match.jsonl | jq -c
{"Name":"Carol","Age":31}
{"Name":"Bob","Age":45}
{"Name":"Alice","Age":20}
cat .snapshot/TestAssert__value_is_match.jsonl | jq
{
"Name": "Carol",
"Age": 31
}
{
"Name": "Bob",
"Age": 45
}
{
"Name": "Alice",
"Age": 20
}
cat .snapshot/TestAssert__value_is_match.jsonl | jq .Name
"Carol"
"Bob"
"Alice"