Skip to content

Latest commit

 

History

History
61 lines (51 loc) · 1.14 KB

README.md

File metadata and controls

61 lines (51 loc) · 1.14 KB

GormShot

GormShot adds Snapshot Testing for GORM.
Inspired by StoryShots.

Install

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

Usage

See: gormshot_test.go

Snapshot file

Snapshot file is saved as JSON Lines format file, so you can use jq command to show pretty output. like this.

example 1 (compact and colored output)

cat .snapshot/TestAssert__value_is_match.jsonl | jq -c
{"Name":"Carol","Age":31}
{"Name":"Bob","Age":45}
{"Name":"Alice","Age":20}

example 2 (formatted output)

cat .snapshot/TestAssert__value_is_match.jsonl | jq 
{
  "Name": "Carol",
  "Age": 31
}
{
  "Name": "Bob",
  "Age": 45
}
{
  "Name": "Alice",
  "Age": 20
}

example 3 (select attribute)

cat .snapshot/TestAssert__value_is_match.jsonl | jq .Name 
"Carol"
"Bob"
"Alice"