Skip to content

📸 GormShot adds Snapshot Testing for GORM.

License

Notifications You must be signed in to change notification settings

nkmr-jp/gormshot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"