[ARVADOS] updated: 40464b75b34b2d6dd11efc681d6274005815bcf9
git at public.curoverse.com
git at public.curoverse.com
Fri Nov 20 16:10:44 EST 2015
Summary of changes:
services/datamanager/keep/keep.go | 9 ++++-----
services/datamanager/keep/keep_test.go | 17 ++++++-----------
2 files changed, 10 insertions(+), 16 deletions(-)
via 40464b75b34b2d6dd11efc681d6274005815bcf9 (commit)
from 74e4c93a1f333352914314b3a53172a0164a20e9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 40464b75b34b2d6dd11efc681d6274005815bcf9
Author: Tom Clegg <tom at curoverse.com>
Date: Fri Nov 20 16:20:33 2015 -0500
7490: Quote strings in error messages, fixup error matching in tests.
diff --git a/services/datamanager/keep/keep.go b/services/datamanager/keep/keep.go
index 5d3d2ed..7da74b1 100644
--- a/services/datamanager/keep/keep.go
+++ b/services/datamanager/keep/keep.go
@@ -309,8 +309,7 @@ func ReadServerResponse(arvLogger *logger.Logger,
resp *http.Response) (response ServerResponse, err error) {
if resp.StatusCode != 200 {
- return response, fmt.Errorf("Received error code %d in response to request "+
- "for %s index: %s",
+ return response, fmt.Errorf("Received error code %d in response to index request for %s: %s",
resp.StatusCode, keepServer.String(), resp.Status)
}
@@ -397,19 +396,19 @@ func parseBlockInfoFromIndexLine(indexLine string) (blockInfo BlockInfo, err err
tokens := strings.Fields(indexLine)
if len(tokens) != 2 {
err = fmt.Errorf("Expected 2 tokens per line but received a "+
- "line containing %v instead.",
+ "line containing %#q instead.",
tokens)
}
var locator blockdigest.BlockLocator
if locator, err = blockdigest.ParseBlockLocator(tokens[0]); err != nil {
- err = fmt.Errorf("%v Received error while parsing line \"%s\"",
+ err = fmt.Errorf("%v Received error while parsing line \"%#q\"",
err, indexLine)
return
}
if len(locator.Hints) > 0 {
err = fmt.Errorf("Block locator in index line should not contain hints "+
- "but it does: %v",
+ "but it does: %#q",
locator)
return
}
diff --git a/services/datamanager/keep/keep_test.go b/services/datamanager/keep/keep_test.go
index 3ca7b82..323a9d1 100644
--- a/services/datamanager/keep/keep_test.go
+++ b/services/datamanager/keep/keep_test.go
@@ -221,27 +221,27 @@ type KeepServerTestData struct {
func (s *KeepSuite) TestGetKeepServers_ErrorGettingKeepServerStatus(c *C) {
testGetKeepServersAndSummarize(c, KeepServerTestData{500, 200, "ok",
- "500 Internal Server Error"})
+ ".*http://.* 500 Internal Server Error"})
}
func (s *KeepSuite) TestGetKeepServers_GettingIndex(c *C) {
testGetKeepServersAndSummarize(c, KeepServerTestData{200, -1, "notok",
- "redirect-loop"})
+ ".*redirect-loop.*"})
}
func (s *KeepSuite) TestGetKeepServers_ErrorReadServerResponse(c *C) {
testGetKeepServersAndSummarize(c, KeepServerTestData{200, 500, "notok",
- "500 Internal Server Error"})
+ ".*http://.* 500 Internal Server Error"})
}
func (s *KeepSuite) TestGetKeepServers_ReadServerResponseTuncatedAtLineOne(c *C) {
testGetKeepServersAndSummarize(c, KeepServerTestData{200, 200,
- "notterminatedwithnewline", "truncated at line 1"})
+ "notterminatedwithnewline", "Index for http://.* truncated at line 1"})
}
func (s *KeepSuite) TestGetKeepServers_InvalidBlockLocatorPattern(c *C) {
testGetKeepServersAndSummarize(c, KeepServerTestData{200, 200, "testing\n",
- "Error parsing BlockInfo from index line"})
+ "Error parsing BlockInfo from index line.*"})
}
func (s *KeepSuite) TestGetKeepServers_ReadServerResponseEmpty(c *C) {
@@ -325,11 +325,6 @@ func testGetKeepServersAndSummarize(c *C, testData KeepServerTestData) {
}
}
} else {
- if testData.expectedError == "Error parsing BlockInfo from index line" {
- // In this case ErrorMatches does not work because the error message contains regexp match characters
- strings.Contains(err.Error(), testData.expectedError)
- } else {
- c.Assert(err, ErrorMatches, fmt.Sprintf(".*%s.*", testData.expectedError))
- }
+ c.Assert(err, ErrorMatches, testData.expectedError)
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list