Skip to content

Commit

Permalink
Merge pull request #35 from mightyguava/patch-1
Browse files Browse the repository at this point in the history
Do not escape JSON
  • Loading branch information
sebdah authored Nov 16, 2020
2 parents f58af5e + df66e94 commit 927dbef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions v2/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,18 @@ func (g *Goldie) Assert(t *testing.T, name string, actualData []byte) {
// `a-z0-9\-\_` is a good idea).
func (g *Goldie) AssertJson(t *testing.T, name string, actualJsonData interface{}) {
t.Helper()
js, err := json.MarshalIndent(actualJsonData, "", " ")
buf := &bytes.Buffer{}
enc := json.NewEncoder(buf)
enc.SetIndent("", " ")
enc.SetEscapeHTML(false)
err := enc.Encode(actualJsonData)

if err != nil {
t.Error(err)
t.FailNow()
}

g.Assert(t, name, normalizeLF(js))
g.Assert(t, name, normalizeLF(buf.Bytes()))
}

// AssertXml compares the actual xml data received with expected data in the
Expand Down

0 comments on commit 927dbef

Please sign in to comment.