16141: Fixes Collection type on Go SDK. Adjusts test.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 10 Feb 2020 15:41:12 +0000 (12:41 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 10 Feb 2020 15:41:12 +0000 (12:41 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

lib/controller/handler_test.go
sdk/go/arvados/collection.go

index 53f5e65c6baebabf4cf14ba829edff51c64d7b25..e8cd1efbad3d26b8e1cfb2fe467ffd9695e68460 100644 (file)
@@ -222,6 +222,9 @@ func (s *HandlerSuite) TestCreateAPIToken(c *check.C) {
 func (s *HandlerSuite) TestGetCollection(c *check.C) {
        var proxied, direct map[string]interface{}
        var err error
+       skippedFields := map[string]bool{
+               "href": true,
+       }
 
        // Get collection from controller
        fooURL := "/arvados/v1/collections/" + arvadostest.FooCollection
@@ -247,18 +250,20 @@ func (s *HandlerSuite) TestGetCollection(c *check.C) {
        err = json.Unmarshal(db, &direct)
        c.Check(err, check.Equals, nil)
 
-       // Check that all railsAPI provided keys exist on the controller response
-       // and their non-nil values are equal.
+       // Check that all RailsAPI provided keys exist on the controller response.
        for k := range direct {
-               if val, ok := proxied[k]; ok {
+               if _, ok := skippedFields[k]; ok {
+                       continue
+               } else if val, ok := proxied[k]; ok {
                        if k == "manifest_text" {
                                // Tokens differ from request to request
                                c.Check(strings.Split(val.(string), "+A")[0], check.Equals, strings.Split(direct[k].(string), "+A")[0])
-                       } else if direct[k] != nil {
-                               c.Check(val, check.DeepEquals, direct[k])
+                       } else {
+                               c.Check(val, check.DeepEquals, direct[k],
+                                       check.Commentf("RailsAPI key %q's value %q differs from controller's %q.", k, direct[k], val))
                        }
                } else {
-                       c.Errorf("Key %q missing", k)
+                       c.Errorf("Key %q missing on controller's response.", k)
                }
        }
 }
index 94390bc01972edcf5008ad493bd928ad91f004b6..623a8d985f6cbe93a903707635447a822c04f3a7 100644 (file)
@@ -24,26 +24,25 @@ type Collection struct {
        Name                      string                 `json:"name"`
        CreatedAt                 time.Time              `json:"created_at"`
        ModifiedAt                time.Time              `json:"modified_at"`
-       ModifiedByClientUUID      string                 `json:"modified_by_client_uuid"`
-       ModifiedByUserUUID        string                 `json:"modified_by_user_uuid"`
+       ModifiedByClientUUID      *string                `json:"modified_by_client_uuid"`
+       ModifiedByUserUUID        *string                `json:"modified_by_user_uuid"`
        PortableDataHash          string                 `json:"portable_data_hash"`
        ReplicationConfirmed      *int                   `json:"replication_confirmed"`
        ReplicationConfirmedAt    *time.Time             `json:"replication_confirmed_at"`
        ReplicationDesired        *int                   `json:"replication_desired"`
        StorageClassesDesired     []string               `json:"storage_classes_desired"`
        StorageClassesConfirmed   []string               `json:"storage_classes_confirmed"`
-       StorageClassesConfirmedAt time.Time              `json:"storage_classes_confirmed_at"`
+       StorageClassesConfirmedAt *time.Time             `json:"storage_classes_confirmed_at"`
        DeleteAt                  *time.Time             `json:"delete_at"`
        IsTrashed                 bool                   `json:"is_trashed"`
        Properties                map[string]interface{} `json:"properties"`
        WritableBy                []string               `json:"writable_by,omitempty"`
-       FileCount                 *int                   `json:"file_count"`
-       FileSizeTotal             *int                   `json:"file_size_total"`
+       FileCount                 int                    `json:"file_count"`
+       FileSizeTotal             int64                  `json:"file_size_total"`
        Version                   *int                   `json:"version"`
        PreserveVersion           bool                   `json:"preserve_version"`
        CurrentVersionUUID        string                 `json:"current_version_uuid"`
-       Description               string                 `json:"description"`
-       Href                      string                 `json:"href"`
+       Description               *string                `json:"description"`
 }
 
 func (c Collection) resourceName() string {