5737: Return of Minitest
[arvados.git] / services / api / test / functional / arvados / v1 / collections_controller_test.rb
index dac960f5d81e5db90331c1978f0e3adffc0fc5b5..634fce79706254069196160410d132e2ed277ae1 100644 (file)
@@ -751,11 +751,11 @@ EOS
     [2**8, :success],
     [2**18, 422],
   ].each do |description_size, expected_response|
-    test "create collection with description size #{description_size}
+    # Descriptions are not part of search indexes. Skip until
+    # full-text search is implemented, at which point replace with a
+    # search in description.
+    skip "create collection with description size #{description_size}
           and expect response #{expected_response}" do
-      skip "(Descriptions are not part of search indexes. Skip until full-text search
-            is implemented, at which point replace with a search in description.)"
-
       authorize_with :active
 
       description = 'here is a collection with a very large description'
@@ -811,41 +811,51 @@ EOS
   end
 
   [
-    nil,
     ". 0:0:foo.txt",
     ". d41d8cd98f00b204e9800998ecf8427e foo.txt",
     "d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt",
     ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt",
   ].each do |manifest_text|
-    test "create collection with invalid manifest #{manifest_text}" do
+    test "create collection with invalid manifest #{manifest_text} and expect error" do
       authorize_with :active
       post :create, {
         collection: {
           manifest_text: manifest_text,
-          portable_data_hash: "d30fe8ae534397864cb96c544f4cf102+47"
+          portable_data_hash: "d41d8cd98f00b204e9800998ecf8427e+0"
         }
       }
       assert_response 422
       response_errors = json_response['errors']
       assert_not_nil response_errors, 'Expected error in response'
-      if manifest_text
-        assert(response_errors.first.include?('Invalid manifest'),
-               "Expected 'Invalid manifest' error in #{response_errors.first}")
-      else
-        assert(response_errors.first.include?('No manifest found'),
-               "Expected 'No manifest found' error in #{response_errors.first}")
-      end
+      assert(response_errors.first.include?('Invalid manifest'),
+             "Expected 'Invalid manifest' error in #{response_errors.first}")
+    end
+  end
+
+  [
+    [nil, "d41d8cd98f00b204e9800998ecf8427e+0"],
+    ["", "d41d8cd98f00b204e9800998ecf8427e+0"],
+    [". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n", "d30fe8ae534397864cb96c544f4cf102+47"],
+  ].each do |manifest_text, pdh|
+    test "create collection with valid manifest #{manifest_text.inspect} and expect success" do
+      authorize_with :active
+      post :create, {
+        collection: {
+          manifest_text: manifest_text,
+          portable_data_hash: pdh
+        }
+      }
+      assert_response 200
     end
   end
 
   [
-    nil,
     ". 0:0:foo.txt",
     ". d41d8cd98f00b204e9800998ecf8427e foo.txt",
     "d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt",
     ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt",
   ].each do |manifest_text|
-    test "update collection with invalid manifest #{manifest_text}" do
+    test "update collection with invalid manifest #{manifest_text} and expect error" do
       authorize_with :active
       post :update, {
         id: 'zzzzz-4zz18-bv31uwvy3neko21',
@@ -856,13 +866,25 @@ EOS
       assert_response 422
       response_errors = json_response['errors']
       assert_not_nil response_errors, 'Expected error in response'
-      if manifest_text
-        assert(response_errors.first.include?('Invalid manifest'),
-               "Expected 'Invalid manifest' error in #{response_errors.first}")
-      else
-        assert(response_errors.first.include?('No manifest found'),
-               "Expected 'No manifest found' error in #{response_errors.first}")
-      end
+      assert(response_errors.first.include?('Invalid manifest'),
+             "Expected 'Invalid manifest' error in #{response_errors.first}")
+    end
+  end
+
+  [
+    nil,
+    "",
+    ". d41d8cd98f00b204e9800998ecf8427e 0:0:foo.txt\n",
+  ].each do |manifest_text|
+    test "update collection with valid manifest #{manifest_text.inspect} and expect success" do
+      authorize_with :active
+      post :update, {
+        id: 'zzzzz-4zz18-bv31uwvy3neko21',
+        collection: {
+          manifest_text: manifest_text,
+        }
+      }
+      assert_response 200
     end
   end
 end