diff --git a/go.mod b/go.mod index 5cc8e1a7e..57fe03ccf 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-test/deep v1.0.4 + github.com/go-test/deep v1.0.8 github.com/google/go-cmp v0.5.7 github.com/gorilla/websocket v1.4.2 github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/go.sum b/go.sum index 194956433..572e89d83 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= -github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= diff --git a/vendor/github.com/go-test/deep/.travis.yml b/vendor/github.com/go-test/deep/.travis.yml index df3972fc9..c459ee7b0 100644 --- a/vendor/github.com/go-test/deep/.travis.yml +++ b/vendor/github.com/go-test/deep/.travis.yml @@ -1,13 +1,13 @@ language: go go: - - "1.10" - - "1.11" - - "1.12" + - "1.15" + - "1.16" + - "1.17" before_install: - go get github.com/mattn/goveralls - go get golang.org/x/tools/cover script: - - $HOME/gopath/bin/goveralls -service=travis-ci + - $HOME/gopath/bin/goveralls -service=travis-pro -package github.com/go-test/deep diff --git a/vendor/github.com/go-test/deep/CHANGES.md b/vendor/github.com/go-test/deep/CHANGES.md index 00f072b18..ade9e79c6 100644 --- a/vendor/github.com/go-test/deep/CHANGES.md +++ b/vendor/github.com/go-test/deep/CHANGES.md @@ -1,5 +1,22 @@ # go-test/deep Changelog +## v1.0.8 released 2021-10-13 + +* Updated matrix to go1.15, go1.16, and go1.17 +* Added SECURITY.md and GitHub code analysis + +## v1.0.7 released 2020-07-11 + +* Fixed issue #39: Confusing diff when comparing distinct types with the same name (PR #44) + +## v1.0.6 released 2020-04-21 + +* Added `NilMapsAreEmpty` variable which causes a nil map to equal an empty map (PR #43) (@yalegko) + +## v1.0.5 released 2020-01-16 + +* Added `NilSlicesAreEmpty` variable which causes a nil slice to be equal to an empty slice (PR #27) (@Anaminus) + ## v1.0.4 released 2019-09-15 * Added \`deep:"-"\` structure field tag to ignore field (PR #38) (@flga) diff --git a/vendor/github.com/go-test/deep/README.md b/vendor/github.com/go-test/deep/README.md index 3b78eac7c..56770a69b 100644 --- a/vendor/github.com/go-test/deep/README.md +++ b/vendor/github.com/go-test/deep/README.md @@ -1,6 +1,6 @@ # Deep Variable Equality for Humans -[![Go Report Card](https://goreportcard.com/badge/github.com/go-test/deep)](https://goreportcard.com/report/github.com/go-test/deep) [![Build Status](https://travis-ci.org/go-test/deep.svg?branch=master)](https://travis-ci.org/go-test/deep) [![Coverage Status](https://coveralls.io/repos/github/go-test/deep/badge.svg?branch=master)](https://coveralls.io/github/go-test/deep?branch=master) [![GoDoc](https://godoc.org/github.com/go-test/deep?status.svg)](https://godoc.org/github.com/go-test/deep) +[![Go Report Card](https://goreportcard.com/badge/github.com/go-test/deep)](https://goreportcard.com/report/github.com/go-test/deep) [![Build Status](https://app.travis-ci.com/go-test/deep.svg?branch=master)](https://app.travis-ci.com/go-test/deep) [![Coverage Status](https://coveralls.io/repos/github/go-test/deep/badge.svg?branch=master)](https://coveralls.io/github/go-test/deep?branch=master) [![GoDoc](https://godoc.org/github.com/go-test/deep?status.svg)](https://pkg.go.dev/github.com/go-test/deep) This package provides a single function: `deep.Equal`. It's like [reflect.DeepEqual](http://golang.org/pkg/reflect/#DeepEqual) but much friendlier to humans (or any sentient being) for two reason: diff --git a/vendor/github.com/go-test/deep/SECURITY.md b/vendor/github.com/go-test/deep/SECURITY.md new file mode 100644 index 000000000..845584a9a --- /dev/null +++ b/vendor/github.com/go-test/deep/SECURITY.md @@ -0,0 +1,17 @@ +# Security Policy + +## Supported Versions + +For security patches, the latest release is supported: + +| Version | Supported | +| ------- | ------------------ | +| 1.0.x | :white_check_mark: | + +## Reporting a Vulnerability + +To report a vulnerability, [create an issue](https://github.com/go-test/deep/issues) with the _security_ label. + +This project is developed and maintained by volunteers during their free time, +so there is no SLA or ETA for fixing vulnerabilities (or any issues). +Please help by submitting a PR to fix an issue. diff --git a/vendor/github.com/go-test/deep/deep.go b/vendor/github.com/go-test/deep/deep.go index 7f8789512..dbc89c04b 100644 --- a/vendor/github.com/go-test/deep/deep.go +++ b/vendor/github.com/go-test/deep/deep.go @@ -29,6 +29,12 @@ var ( // CompareUnexportedFields causes unexported struct fields, like s in // T{s int}, to be compared when true. CompareUnexportedFields = false + + // NilSlicesAreEmpty causes a nil slice to be equal to an empty slice. + NilSlicesAreEmpty = false + + // NilMapsAreEmpty causes a nil map to be equal to an empty map. + NilMapsAreEmpty = false ) var ( @@ -106,7 +112,18 @@ func (c *cmp) equals(a, b reflect.Value, level int) { aType := a.Type() bType := b.Type() if aType != bType { - c.saveDiff(aType, bType) + // Built-in types don't have a name, so don't report [3]int != [2]int as " != " + if aType.Name() == "" || aType.Name() != bType.Name() { + c.saveDiff(aType, bType) + } else { + // Type names can be the same, e.g. pkg/v1.Error and pkg/v2.Error + // are both exported as pkg, so unless we include the full pkg path + // the diff will be "pkg.Error != pkg.Error" + // https://github.com/go-test/deep/issues/39 + aFullType := aType.PkgPath() + "." + aType.Name() + bFullType := bType.PkgPath() + "." + bType.Name() + c.saveDiff(aFullType, bFullType) + } logError(ErrTypeMismatch) return } @@ -228,10 +245,20 @@ func (c *cmp) equals(a, b reflect.Value, level int) { */ if a.IsNil() || b.IsNil() { - if a.IsNil() && !b.IsNil() { - c.saveDiff("", b) - } else if !a.IsNil() && b.IsNil() { - c.saveDiff(a, "") + if NilMapsAreEmpty { + if a.IsNil() && b.Len() != 0 { + c.saveDiff("", b) + return + } else if a.Len() != 0 && b.IsNil() { + c.saveDiff(a, "") + return + } + } else { + if a.IsNil() && !b.IsNil() { + c.saveDiff("", b) + } else if !a.IsNil() && b.IsNil() { + c.saveDiff(a, "") + } } return } @@ -241,7 +268,7 @@ func (c *cmp) equals(a, b reflect.Value, level int) { } for _, key := range a.MapKeys() { - c.push(fmt.Sprintf("map[%s]", key)) + c.push(fmt.Sprintf("map[%v]", key)) aVal := a.MapIndex(key) bVal := b.MapIndex(key) @@ -263,7 +290,7 @@ func (c *cmp) equals(a, b reflect.Value, level int) { continue } - c.push(fmt.Sprintf("map[%s]", key)) + c.push(fmt.Sprintf("map[%v]", key)) c.saveDiff("", b.MapIndex(key)) c.pop() if len(c.diff) >= MaxDiff { @@ -281,13 +308,22 @@ func (c *cmp) equals(a, b reflect.Value, level int) { } } case reflect.Slice: - if a.IsNil() || b.IsNil() { + if NilSlicesAreEmpty { + if a.IsNil() && b.Len() != 0 { + c.saveDiff("", b) + return + } else if a.Len() != 0 && b.IsNil() { + c.saveDiff(a, "") + return + } + } else { if a.IsNil() && !b.IsNil() { c.saveDiff("", b) + return } else if !a.IsNil() && b.IsNil() { c.saveDiff(a, "") + return } - return } aLen := a.Len() @@ -321,8 +357,13 @@ func (c *cmp) equals(a, b reflect.Value, level int) { ///////////////////////////////////////////////////////////////////// case reflect.Float32, reflect.Float64: - // Avoid 0.04147685731961082 != 0.041476857319611 - // 6 decimal places is close enough + // Round floats to FloatPrecision decimal places to compare with + // user-defined precision. As is commonly know, floats have "imprecision" + // such that 0.1 becomes 0.100000001490116119384765625. This cannot + // be avoided; it can only be handled. Issue 30 suggested that floats + // be compared using an epsilon: equal = |a-b| < epsilon. + // In many cases the result is the same, but I think epsilon is a little + // less clear for users to reason about. See issue 30 for details. aval := fmt.Sprintf(c.floatFormat, a.Float()) bval := fmt.Sprintf(c.floatFormat, b.Float()) if aval != bval { diff --git a/vendor/github.com/go-test/deep/go.mod b/vendor/github.com/go-test/deep/go.mod index 6e8ca1d2b..021ffba07 100644 --- a/vendor/github.com/go-test/deep/go.mod +++ b/vendor/github.com/go-test/deep/go.mod @@ -1 +1,3 @@ module github.com/go-test/deep + +go 1.16 diff --git a/vendor/github.com/go-test/deep/go.sum b/vendor/github.com/go-test/deep/go.sum new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/modules.txt b/vendor/modules.txt index cca25c04d..d8c72af6c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/go-test/deep v1.0.4 +# github.com/go-test/deep v1.0.8 ## explicit github.com/go-test/deep # github.com/google/go-cmp v0.5.7