6859: add one more test with error during arv-put
authorradhika <radhika@curoverse.com>
Mon, 17 Aug 2015 14:58:48 +0000 (10:58 -0400)
committerradhika <radhika@curoverse.com>
Mon, 17 Aug 2015 14:58:48 +0000 (10:58 -0400)
services/api/test/unit/salvage_collection_test.rb

index 4cc5378073767df6fffe916f4ce08701afb0ad04..09ab6cfac089ee70c216505377667e27d9d75a3e 100644 (file)
@@ -6,9 +6,16 @@ TEST_MANIFEST = ". 341dabea2bd78ad0d6fc3f5b926b450e+85626+Ad391622a17f61e4a254ed
 module Kernel
   def `(cmd)    # override kernel ` method
     if cmd.include? 'arv-put'
-      ". " +
-      Digest::MD5.hexdigest(TEST_MANIFEST) +
-      " 0:" + TEST_MANIFEST.length.to_s + ":invalid_manifest_text.txt\n"
+      file_contents = file = File.new(cmd.split[-1], "r").gets
+
+      # simulate arv-put error when it is 'user_agreement'
+      if file_contents.include? 'GNU_General_Public_License'
+        return ''
+      else
+        ". " +
+        Digest::MD5.hexdigest(TEST_MANIFEST) +
+        " 0:" + TEST_MANIFEST.length.to_s + ":invalid_manifest_text.txt\n"
+      end
     end
   end
 
@@ -79,4 +86,10 @@ class SalvageCollectionTest < ActiveSupport::TestCase
     end
     assert_equal true, exited
   end
+
+  test "salvage collection with during arv-put" do
+    # try to salvage collection while mimicking error during arv-put
+    status = SalvageCollection.salvage_collection collections('user_agreement').uuid
+    assert_equal false, status
+  end
 end