[ARVADOS] updated: 1.3.0-613-gdd2e6f664

Git user git at public.curoverse.com
Mon Apr 1 18:49:53 UTC 2019


Summary of changes:
 .../arvados/v1/collections_controller_test.rb      | 75 ++++++++++++++++++++++
 services/api/test/unit/collection_test.rb          | 27 +++++---
 2 files changed, 93 insertions(+), 9 deletions(-)

       via  dd2e6f664a3e59e02349901a04e182bda6286f6f (commit)
      from  fc636d5e169d944981ce2951e05d59fad04563a3 (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 dd2e6f664a3e59e02349901a04e182bda6286f6f
Author: Eric Biagiotti <ebiagiotti at veritasgenetics.com>
Date:   Mon Apr 1 14:49:42 2019 -0400

    14844: Adds collections controller tests and updates collection model tests
    
    Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti at veritasgenetics.com>

diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb
index 997d89d5c..3bcb1ec1b 100644
--- a/services/api/test/functional/arvados/v1/collections_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb
@@ -938,6 +938,81 @@ EOS
   end
 
   [
+    [". d41d8cd98f00b204e9800998ecf8427e 0:34:foo.txt\n", 1, 34],
+    [". d41d8cd98f00b204e9800998ecf8427e 0:34:foo.txt 0:30:foo.txt 0:30:foo1.txt 0:30:foo2.txt 0:30:foo3.txt 0:30:foo4.txt\n", 5, 184],
+    [". d41d8cd98f00b204e9800998ecf8427e 0:0:.\n", 0, 0]
+  ].each do |manifest, count, size|
+    test "create collection with valid manifest #{manifest} and expect file stats" do
+      authorize_with :active
+      post :create, {
+        collection: {
+          manifest_text: manifest
+        }
+      }
+      assert_response 200
+      assert_equal count, json_response['file_count']
+      assert_equal size, json_response['file_size_total']
+    end
+  end
+
+  test "create collection with file stats and expect overwrite" do
+    authorize_with :active
+    post :create, {
+      collection: {
+        manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:34:foo.txt\n",
+        file_count: 10,
+        file_size_total: 100
+      }
+    }
+    assert_response 200
+    assert_equal 1, json_response['file_count']
+    assert_equal 34, json_response['file_size_total']
+  end
+
+  test "update collection manifest and expect file stats" do
+    authorize_with :active
+    post :update, {
+      id: 'zzzzz-4zz18-bv31uwvy3neko21',
+      collection: {
+        manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:34:foo.txt\n"
+      }
+    }
+    assert_response 200
+    assert_equal 1, json_response['file_count']
+    assert_equal 34, json_response['file_size_total']
+  end
+
+  test "update collection file count and expect error" do
+    authorize_with :active
+    post :update, {
+      id: 'zzzzz-4zz18-znfnqtbbv4spc3w',
+      collection: {
+        file_count: 10
+      }
+    }
+    assert_response 422
+    response_errors = json_response['errors']
+    assert_not_nil response_errors, 'Expected error in response'
+    assert(response_errors.first.include?('File count cannot be changed'),
+           "Expected file count error in #{response_errors.first}")
+  end
+
+  test "update collection file size and expect error" do
+    authorize_with :active
+    post :update, {
+      id: 'zzzzz-4zz18-znfnqtbbv4spc3w',
+      collection: {
+        file_size_total: 10
+      }
+    }
+    assert_response 422
+    response_errors = json_response['errors']
+    assert_not_nil response_errors, 'Expected error in response'
+    assert(response_errors.first.include?('File size total cannot be changed'),
+           "Expected file size total error in #{response_errors.first}")
+  end
+
+  [
     ". 0:0:foo.txt",
     ". d41d8cd98f00b204e9800998ecf8427e foo.txt",
     "d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt",
diff --git a/services/api/test/unit/collection_test.rb b/services/api/test/unit/collection_test.rb
index a0fa3cac9..8538b35b3 100644
--- a/services/api/test/unit/collection_test.rb
+++ b/services/api/test/unit/collection_test.rb
@@ -64,31 +64,40 @@ class CollectionTest < ActiveSupport::TestCase
     [". d41d8cd98f00b204e9800998ecf8427e 0:34:foo.txt\n", 1, 34],
     [". d41d8cd98f00b204e9800998ecf8427e 0:34:foo.txt 0:30:foo.txt 0:30:foo1.txt 0:30:foo2.txt 0:30:foo3.txt 0:30:foo4.txt\n", 5, 184],
     [". d41d8cd98f00b204e9800998ecf8427e 0:0:.\n", 0, 0]
-  ].each do |t|
-    test "file stats on create collection with #{t[0]}" do
+  ].each do |manifest, count, size|
+    test "file stats on create collection with #{manifest}" do
       act_as_system_user do
-        c = Collection.create(manifest_text: t[0])
-        assert_equal t[1], c.file_count
-        assert_equal t[2], c.file_size_total
+        c = Collection.create(manifest_text: manifest)
+        assert_equal count, c.file_count
+        assert_equal size, c.file_size_total
       end
     end
   end
 
   test "file stats cannot be changed unless through manifest change" do
     act_as_system_user do
+      # Changing file stats via an update should fail validation
       c = Collection.create(manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:34:foo.txt\n")
-      assert c.valid?
       c.file_count = 6
       c.file_size_total = 30
       assert !c.valid?
       c.reload
       assert_equal 1, c.file_count
       assert_equal 34, c.file_size_total
-      c.update(manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:10:foo.txt 0:10:foo2.txt\n")
-      assert c.valid?
+
+      # Changing the file stats via manifest change validates
+      c = Collection.create(manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:34:foo.txt 0:34:foo2.txt\n")
       c.reload
+      assert c.valid?
       assert_equal 2, c.file_count
-      assert_equal 20, c.file_size_total
+      assert_equal 68, c.file_size_total
+
+      # Changing file stats at create, will silently overwrite
+      c = Collection.create(manifest_text: ". d41d8cd98f00b204e9800998ecf8427e 0:34:foo.txt\n", file_count: 10, file_size_total: 10)
+      c.reload
+      assert c.valid?
+      assert_equal 1, c.file_count
+      assert_equal 34, c.file_size_total
     end
   end
 

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list