Skip to content

Commit

Permalink
dropping unneeded nasty hack
Browse files Browse the repository at this point in the history
  • Loading branch information
jprobinson committed Dec 13, 2022
1 parent 55444a1 commit d3f048e
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions assert/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"unicode/utf8"

"github.com/davecgh/go-spew/spew"
gogo "github.com/gogo/protobuf/proto"
protov1 "github.com/golang/protobuf/proto"
"github.com/pmezard/go-difflib/difflib"
"google.golang.org/protobuf/proto"
yaml "gopkg.in/yaml.v3"
Expand Down Expand Up @@ -70,28 +68,6 @@ func ObjectsAreEqual(expected, actual interface{}) (eq bool) {
return proto.Equal(exp, act)
}
}
// check v1 protobufs
if exp, ok := expected.(protov1.Message); ok {
if act, ok := actual.(protov1.Message); ok {
// 🚨HACK ALERT!🚨
// There's no way to detect that this was protov1 or gogo/protobuf as they
// share the same interface BUT the Equal func for protov1 will _panic_ if it
// encounters a gogo generated struct.
// If a panic occurs, this will recover and attempt to compare it as a gogo
// struct.
defer func() {
if r := recover(); r != nil {
fmt.Println("recovered from a protov1 panic in DD's forked testify package. please consider using proto.Equal instead.")
if exp, ok := expected.(gogo.Message); ok {
if act, ok := actual.(gogo.Message); ok {
eq = gogo.Equal(exp, act)
}
}
}
}()
return protov1.Equal(exp, act)
}
}

exp, ok := expected.([]byte)
if !ok {
Expand Down

0 comments on commit d3f048e

Please sign in to comment.