Merge branch 'master' into 4523-search-index
[arvados.git] / services / api / test / unit / collection_test.rb
index 1a5eee94c9ccfe6149d0f8b3a446150a2f3542ea..0134ec2864fd3da66419557c548fb911959c3770 100644 (file)
@@ -51,22 +51,28 @@ class CollectionTest < ActiveSupport::TestCase
     end
   end
 
-  test 'create collection with large manifest text and verify file_names' do
-    act_as_system_user do
-      manifest_text = ". d41d8cd98f00b204e9800998ecf8427e+0"
-      index = 0
-      while manifest_text.length < 2**15
-        manifest_text += ' ' + "0:0:foo#{index}.txt"
-        index += 1
-      end
-      manifest_text += "\n"
+  [
+    2**8,
+    2**18,
+  ].each do |manifest_size|
+    test "create collection with manifest size #{manifest_size} and
+          not expect exceptions even on very large manifest texts" do
+      # file_names has a max size, hence there will be no errors even on large manifests
+      act_as_system_user do
+        manifest_text = '. d41d8cd98f00b204e9800998ecf8427e+0'
+        index = 0
+        while manifest_text.length < manifest_size
+          manifest_text += ' ' + "0:0:veryverylongfilename000000000000#{index}.txt"
+          index += 1
+        end
+        manifest_text += "\n"
 
-      c = Collection.create(manifest_text: manifest_text)
+        c = Collection.create(manifest_text: manifest_text)
 
-      assert c.valid?
-      created_file_names = c.file_names
-      assert created_file_names
+        assert c.valid?
+        created_file_names = c.file_names
+        assert created_file_names
+      end
     end
   end
-
 end