aboutsummaryrefslogtreecommitdiffstats
path: root/library/go/test
diff options
context:
space:
mode:
authorhcpp <hcpp@ydb.tech>2023-11-08 12:09:41 +0300
committerhcpp <hcpp@ydb.tech>2023-11-08 12:56:14 +0300
commita361f5b98b98b44ea510d274f6769164640dd5e1 (patch)
treec47c80962c6e2e7b06798238752fd3da0191a3f6 /library/go/test
parent9478806fde1f4d40bd5a45e7cbe77237dab613e9 (diff)
downloadydb-a361f5b98b98b44ea510d274f6769164640dd5e1.tar.gz
metrics have been added
Diffstat (limited to 'library/go/test')
-rw-r--r--library/go/test/assertpb/assert.go35
-rw-r--r--library/go/test/assertpb/ya.make9
2 files changed, 44 insertions, 0 deletions
diff --git a/library/go/test/assertpb/assert.go b/library/go/test/assertpb/assert.go
new file mode 100644
index 0000000000..f5420748d2
--- /dev/null
+++ b/library/go/test/assertpb/assert.go
@@ -0,0 +1,35 @@
+package assertpb
+
+import (
+ "fmt"
+
+ "github.com/golang/protobuf/proto"
+ "github.com/google/go-cmp/cmp"
+ "github.com/stretchr/testify/assert"
+)
+
+type TestingT interface {
+ Errorf(format string, args ...interface{})
+ FailNow()
+ Helper()
+}
+
+func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
+ t.Helper()
+
+ if cmp.Equal(expected, actual, cmp.Comparer(proto.Equal)) {
+ return true
+ }
+
+ diff := cmp.Diff(expected, actual, cmp.Comparer(proto.Equal))
+ return assert.Fail(t, fmt.Sprintf("Not equal: \n"+
+ "expected: %s\n"+
+ "actual : %s\n"+
+ "diff : %s", expected, actual, diff), msgAndArgs)
+}
+
+func Equalf(t TestingT, expected, actual interface{}, msg string, args ...interface{}) bool {
+ t.Helper()
+
+ return Equal(t, expected, actual, append([]interface{}{msg}, args...)...)
+}
diff --git a/library/go/test/assertpb/ya.make b/library/go/test/assertpb/ya.make
new file mode 100644
index 0000000000..109571f55a
--- /dev/null
+++ b/library/go/test/assertpb/ya.make
@@ -0,0 +1,9 @@
+GO_LIBRARY()
+
+SRCS(assert.go)
+
+GO_TEST_SRCS(assert_test.go)
+
+END()
+
+RECURSE(gotest)