Skip to content

Commit 43df43d

Browse files
committed
update gop to support MaxDepth
1 parent 6206d9a commit 43df43d

10 files changed

Lines changed: 12 additions & 11 deletions

File tree

assertions_error.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ type defaultAssertionError struct {
9595
}
9696

9797
// NewDefaultAssertionError handler
98-
func NewDefaultAssertionError(theme gop.Theme, diffTheme diff.Theme) AssertionError {
98+
func NewDefaultAssertionError(maxDepth int, theme gop.Theme, diffTheme diff.Theme) AssertionError {
9999
f := func(v interface{}) string {
100-
return gop.Format(gop.Tokenize(v), theme)
100+
return gop.Format(gop.TokenizeWithOptions(v, gop.Options{MaxDepth: maxDepth}), theme)
101101
}
102102

103103
k := func(s string) string {

assertions_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func TestAssertion(t *testing.T) {
9494
func TestAssertionErr(t *testing.T) {
9595
m := &mock{t: t}
9696
as := got.New(m)
97-
as.Assertions.ErrorHandler = got.NewDefaultAssertionError(gop.ThemeNone, nil)
97+
as.Assertions.ErrorHandler = got.NewDefaultAssertionError(15, gop.ThemeNone, nil)
9898

9999
type data struct {
100100
A int

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/ysmood/got
22

33
go 1.21
44

5-
require github.com/ysmood/gop v0.2.0
5+
require github.com/ysmood/gop v0.3.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github.com/ysmood/gop v0.2.0 h1:+tFrG0TWPxT6p9ZaZs+VY+opCvHU8/3Fk6BaNv6kqKg=
2-
github.com/ysmood/gop v0.2.0/go.mod h1:rr5z2z27oGEbyB787hpEcx4ab8cCiPnKxn0SUHt6xzk=
1+
github.com/ysmood/gop v0.3.0 h1:b/t6tbGSIaSqfnhb1R6Xkye4ZkINfKiUxYZF33JEZWU=
2+
github.com/ysmood/gop v0.3.0/go.mod h1:K4LAB/BdLArknXrVSy+DyXcfb8P85JwAtwYM8zlb0mU=

go.work.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
22
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
33
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
44
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
5+
github.com/ysmood/gop v0.2.0/go.mod h1:rr5z2z27oGEbyB787hpEcx4ab8cCiPnKxn0SUHt6xzk=
56
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=

got.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func T(t Testable) G {
5353

5454
// New G instance
5555
func New(t Testable) G {
56-
eh := NewDefaultAssertionError(gop.ThemeDefault, diff.ThemeDefault)
56+
eh := NewDefaultAssertionError(15, gop.ThemeDefault, diff.ThemeDefault)
5757

5858
g := G{
5959
t,

lib/diff/format_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
var setup = got.Setup(func(g got.G) {
15-
g.ErrorHandler = got.NewDefaultAssertionError(nil, nil)
15+
g.ErrorHandler = got.NewDefaultAssertionError(15, nil, nil)
1616
})
1717

1818
func split(s string) []string { return strings.Split(s, "") }

lib/example/06_customize_assertion_output_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func TestCustomizeAssertionOutput(t *testing.T) {
1414
g := got.New(t)
1515

16-
dh := got.NewDefaultAssertionError(gop.ThemeDefault, diff.ThemeDefault)
16+
dh := got.NewDefaultAssertionError(10, gop.ThemeDefault, diff.ThemeDefault)
1717
h := got.AssertionErrorReport(func(c *got.AssertionCtx) string {
1818
if c.Type == got.AssertionEq {
1919
return fmt.Sprintf("%v != %v", c.Details[0], c.Details[1])

lib/lcs/lcs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
var setup = got.Setup(func(g got.G) {
16-
g.ErrorHandler = got.NewDefaultAssertionError(nil, nil)
16+
g.ErrorHandler = got.NewDefaultAssertionError(15, nil, nil)
1717
})
1818

1919
func TestLCS(t *testing.T) {

snapshots_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestSnapshots(t *testing.T) {
3535
g.Has(m.msg, "diff chunk")
3636
m.reset()
3737

38-
gm.ErrorHandler = got.NewDefaultAssertionError(gop.ThemeNone, nil)
38+
gm.ErrorHandler = got.NewDefaultAssertionError(15, gop.ThemeNone, nil)
3939
gm.Snapshot("a", "no")
4040
m.checkWithStyle(true, `"no" ⦗not ==⦘ "ok"`)
4141
}

0 commit comments

Comments
 (0)