-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syncing up to 1ee5e7e70788927381a5077476b391cbad9eb27a
Co-authored-by: Joey Greco <57115019+joeyagreco@users.noreply.github.com> Co-authored-by: Bruce Yu <bruce@superblockshq.com>
- Loading branch information
1 parent
41a3cae
commit e7efa92
Showing
7 changed files
with
384 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package utils | ||
|
||
import ( | ||
"github.com/google/go-cmp/cmp" | ||
"google.golang.org/protobuf/proto" | ||
"google.golang.org/protobuf/testing/protocmp" | ||
) | ||
|
||
/* | ||
QOL function to compare 2 proto objects in a unit test. | ||
Will compare the given proto messages and print out a nice message showing the diff. | ||
*/ | ||
func ProtoEquals(tb FatalTB, expected proto.Message, actual proto.Message) { | ||
if d := cmp.Diff(expected, actual, protocmp.Transform()); d != "" { | ||
tb.Fatalf("unexpected diff\n%s", d) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package utils | ||
|
||
import ( | ||
"testing" | ||
|
||
apiv1 "github.com/superblocksteam/agent/types/gen/go/api/v1" | ||
"google.golang.org/protobuf/proto" | ||
) | ||
|
||
func Test_ProtoEquals(t *testing.T) { | ||
t.Parallel() | ||
|
||
for _, test := range []struct { | ||
name string | ||
proto1 proto.Message | ||
proto2 proto.Message | ||
expectTestFailure bool | ||
}{ | ||
{ | ||
name: "equal", | ||
proto1: &apiv1.Blocks{}, | ||
proto2: &apiv1.Blocks{}, | ||
}, | ||
{ | ||
name: "not equal", | ||
proto1: &apiv1.Blocks{}, | ||
proto2: &apiv1.Blocks{Blocks: []*apiv1.Block{{Name: "foo"}}}, | ||
expectTestFailure: true, | ||
}, | ||
} { | ||
t.Run(test.name, func(t *testing.T) { | ||
ProtoEquals(newFakeTB(t, test.expectTestFailure), test.proto1, test.proto2) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.