Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: common/testing/assertions/error_tests.go

Issue 2576923003: Implement config service cache on top of datastore (Closed)
Patch Set: Relocated, fix, split integration test, rebase. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/gaemiddleware/routes.go ('k') | luci_config/appengine/backend/datastore/ds.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/testing/assertions/error_tests.go
diff --git a/common/testing/assertions/error_tests.go b/common/testing/assertions/error_tests.go
index fa309ba7daae62d2eadc299f35585fe0983d6e9b..5aa2146e81d9ea2bf7af45cee8f67655ecce6cd7 100644
--- a/common/testing/assertions/error_tests.go
+++ b/common/testing/assertions/error_tests.go
@@ -7,6 +7,8 @@ package assertions
import (
"fmt"
+ "github.com/luci/luci-go/common/errors"
+
"github.com/smartystreets/assertions"
)
@@ -67,3 +69,24 @@ func ShouldPanicLike(function interface{}, expected ...interface{}) (ret string)
f()
return ShouldErrLike(nil, expected...)
}
+
+// ShouldUnwrapTo asserts that an error, when unwrapped, equals another error.
+//
+// The actual field will be unwrapped using errors.Unwrap and then compared to
+// the error in expected.
+func ShouldUnwrapTo(actual interface{}, expected ...interface{}) string {
+ act, ok := actual.(error)
+ if !ok {
+ return fmt.Sprintf("ShouldUnwrapTo requires an error actual type, got %T", act)
+ }
+
+ if len(expected) != 1 {
+ return fmt.Sprintf("ShouldUnwrapTo requires exactly one expected value, got %d", len(expected))
+ }
+ exp, ok := expected[0].(error)
+ if !ok {
+ return fmt.Sprintf("ShouldUnwrapTo requires an error expected type, got %T", expected[0])
+ }
+
+ return assertions.ShouldEqual(errors.Unwrap(act), exp)
+}
« no previous file with comments | « appengine/gaemiddleware/routes.go ('k') | luci_config/appengine/backend/datastore/ds.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698