gormshot

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2022 License: MIT Imports: 10 Imported by: 0

README

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"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(db *gorm.DB) *gormShot

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL