[ARVADOS] updated: 094d247c7aaddbcd0a512887c6ce115558d14f72

git at public.curoverse.com git at public.curoverse.com
Tue Aug 11 17:16:11 EDT 2015


Summary of changes:
 sdk/go/arvadosclient/arvadosclient.go      | 16 +++++++-------
 sdk/go/arvadosclient/arvadosclient_test.go | 34 ++++++++++++++++++++++++++++--
 2 files changed, 40 insertions(+), 10 deletions(-)

       via  094d247c7aaddbcd0a512887c6ce115558d14f72 (commit)
       via  2566020d5e03c6934b9ae6c8b70368da1d03f526 (commit)
      from  98feead9acd503a81c69b06bf07d6c1bfd3dd458 (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 094d247c7aaddbcd0a512887c6ce115558d14f72
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Aug 11 15:38:40 2015 -0400

    5824: Add tests for UUIDMatch and PDHMatch.

diff --git a/sdk/go/arvadosclient/arvadosclient_test.go b/sdk/go/arvadosclient/arvadosclient_test.go
index 65a5c10..acdf091 100644
--- a/sdk/go/arvadosclient/arvadosclient_test.go
+++ b/sdk/go/arvadosclient/arvadosclient_test.go
@@ -14,6 +14,7 @@ func Test(t *testing.T) {
 }
 
 var _ = Suite(&ServerRequiredSuite{})
+var _ = Suite(&UnitSuite{})
 
 // Tests that require the Keep server running
 type ServerRequiredSuite struct{}
@@ -152,3 +153,33 @@ func (s *ServerRequiredSuite) TestAPIDiscovery_Get_noSuchParameter(c *C) {
 	c.Assert(err, NotNil)
 	c.Assert(value, IsNil)
 }
+
+type UnitSuite struct{}
+
+func (s *UnitSuite) TestUUIDMatch(c *C) {
+	c.Assert(UUIDMatch("zzzzz-tpzed-000000000000000"), Equals, true)
+	c.Assert(UUIDMatch("zzzzz-zebra-000000000000000"), Equals, true)
+	c.Assert(UUIDMatch("00000-00000-zzzzzzzzzzzzzzz"), Equals, true)
+	c.Assert(UUIDMatch("ZEBRA-HORSE-AFRICANELEPHANT"), Equals, false)
+	c.Assert(UUIDMatch(" zzzzz-tpzed-000000000000000"), Equals, false)
+	c.Assert(UUIDMatch("d41d8cd98f00b204e9800998ecf8427e"), Equals, false)
+	c.Assert(UUIDMatch("d41d8cd98f00b204e9800998ecf8427e+0"), Equals, false)
+	c.Assert(UUIDMatch(""), Equals, false)
+}
+
+func (s *UnitSuite) TestPDHMatch(c *C) {
+	c.Assert(PDHMatch("zzzzz-tpzed-000000000000000"), Equals, false)
+	c.Assert(PDHMatch("d41d8cd98f00b204e9800998ecf8427e"), Equals, false)
+	c.Assert(PDHMatch("d41d8cd98f00b204e9800998ecf8427e+0"), Equals, true)
+	c.Assert(PDHMatch("d41d8cd98f00b204e9800998ecf8427e+12345"), Equals, true)
+	c.Assert(PDHMatch("d41d8cd98f00b204e9800998ecf8427e 12345"), Equals, false)
+	c.Assert(PDHMatch("D41D8CD98F00B204E9800998ECF8427E+12345"), Equals, false)
+	c.Assert(PDHMatch("d41d8cd98f00b204e9800998ecf8427e+12345 "), Equals, false)
+	c.Assert(PDHMatch("d41d8cd98f00b204e9800998ecf8427e+abcdef"), Equals, false)
+	c.Assert(PDHMatch("da39a3ee5e6b4b0d3255bfef95601890afd80709"), Equals, false)
+	c.Assert(PDHMatch("da39a3ee5e6b4b0d3255bfef95601890afd80709+0"), Equals, false)
+	c.Assert(PDHMatch("d41d8cd98f00b204e9800998ecf8427+12345"), Equals, false)
+	c.Assert(PDHMatch("d41d8cd98f00b204e9800998ecf8427e+12345\n"), Equals, false)
+	c.Assert(PDHMatch("+12345"), Equals, false)
+	c.Assert(PDHMatch(""), Equals, false)
+}

commit 2566020d5e03c6934b9ae6c8b70368da1d03f526
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Aug 11 15:37:50 2015 -0400

    5824: Return InvalidArgument (not 404) for poor argument choices that do not involve real HTTP failures.

diff --git a/sdk/go/arvadosclient/arvadosclient.go b/sdk/go/arvadosclient/arvadosclient.go
index e43162f..1cce0a7 100644
--- a/sdk/go/arvadosclient/arvadosclient.go
+++ b/sdk/go/arvadosclient/arvadosclient.go
@@ -23,6 +23,7 @@ var PDHMatch StringMatcher = regexp.MustCompile(`^[0-9a-f]{32}\+\d+$`).MatchStri
 
 var MissingArvadosApiHost = errors.New("Missing required environment variable ARVADOS_API_HOST")
 var MissingArvadosApiToken = errors.New("Missing required environment variable ARVADOS_API_TOKEN")
+var ErrInvalidArgument = errors.New("Invalid argument")
 
 // Indicates an error that was returned by the API server.
 type APIServerError struct {
@@ -247,16 +248,12 @@ func (c ArvadosClient) Update(resourceType string, uuid string, parameters Dict,
 
 // Get a resource. See Call for argument descriptions.
 func (c ArvadosClient) Get(resourceType string, uuid string, parameters Dict, output interface{}) (err error) {
-	if uuid == "" {
+	if !UUIDMatch(uuid) && !(resourceType == "collections" && PDHMatch(uuid)) {
 		// No object has uuid == "": there is no need to make
 		// an API call. Furthermore, the HTTP request for such
 		// an API call would be "GET /arvados/v1/type/", which
 		// is liable to be misinterpreted as the List API.
-		return APIServerError{
-			ServerAddress:     c.ApiServer,
-			HttpStatusCode:    http.StatusNotFound,
-			HttpStatusMessage: "Not Found",
-		}
+		return ErrInvalidArgument
 	}
 	return c.Call("GET", resourceType, uuid, "", parameters, output)
 }
@@ -268,7 +265,10 @@ func (c ArvadosClient) List(resource string, parameters Dict, output interface{}
 
 const API_DISCOVERY_RESOURCE = "discovery/v1/apis/arvados/v1/rest"
 
-// Discovery returns the value of the given parameter in the discovery document.
+// Discovery returns the value of the given parameter in the discovery
+// document. Returns a non-nil error if the discovery document cannot
+// be retrieved/decoded. Returns ErrInvalidArgument if the requested
+// parameter is not found in the discovery document.
 func (c *ArvadosClient) Discovery(parameter string) (value interface{}, err error) {
 	if len(c.DiscoveryDoc) == 0 {
 		c.DiscoveryDoc = make(Dict)
@@ -283,6 +283,6 @@ func (c *ArvadosClient) Discovery(parameter string) (value interface{}, err erro
 	if found {
 		return value, nil
 	} else {
-		return value, errors.New("Not found")
+		return value, ErrInvalidArgument
 	}
 }
diff --git a/sdk/go/arvadosclient/arvadosclient_test.go b/sdk/go/arvadosclient/arvadosclient_test.go
index 249505e..65a5c10 100644
--- a/sdk/go/arvadosclient/arvadosclient_test.go
+++ b/sdk/go/arvadosclient/arvadosclient_test.go
@@ -51,8 +51,7 @@ func (s *ServerRequiredSuite) TestGetEmptyUUID(c *C) {
 
 	getback := make(Dict)
 	err = arv.Get("collections", "", nil, &getback)
-	c.Assert(err, FitsTypeOf, APIServerError{})
-	c.Assert(err.(APIServerError).HttpStatusCode, Equals, http.StatusNotFound)
+	c.Assert(err, Equals, ErrInvalidArgument)
 	c.Assert(len(getback), Equals, 0)
 }
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list