Allow extractCommonProperties to return an error
Refactoring in preparation for follow up changes.
Also:
* Adds a new AssertErrorMessageEquals() helper method.
* Improved error reporting in the accessor and added name to
extractorProperty to ensure meaningful errors are reported.
* Added String() string method to propertiesContainer.
* Reports errors using the field name as the errors are not really
fixable by developers and it is more meaningful to the build team.
Bug: 155628860
Test: m nothing
Change-Id: I5c5b8436bcbc39e4e7cd35df2577b2dac53e702a
diff --git a/sdk/testing.go b/sdk/testing.go
index 9e27201..14a397c 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -173,6 +173,15 @@
}
}
+func (h *TestHelper) AssertErrorMessageEquals(message string, expected string, actual error) {
+ h.t.Helper()
+ if actual == nil {
+ h.t.Errorf("Expected error but was nil")
+ } else if actual.Error() != expected {
+ h.t.Errorf("%s: expected %s, actual %s", message, expected, actual.Error())
+ }
+}
+
func (h *TestHelper) AssertTrimmedStringEquals(message string, expected string, actual string) {
h.t.Helper()
h.AssertStringEquals(message, strings.TrimSpace(expected), strings.TrimSpace(actual))