Merge pull request #1 from curoverse/master
[arvados.git] / sdk / cli / test / test_arv-put.rb
index 53f05deb716f59eb17331c37734e692603b456dc..73513db56cb17ee5f6d88d151205f437e6d22107 100644 (file)
@@ -14,15 +14,16 @@ class TestArvPut < Minitest::Test
 
   def test_help
     out, err = capture_subprocess_io do
-      assert_equal(true, arv_put('-h'),
-                   'arv-put -h exits zero')
+      assert arv_put('-h'), 'arv-put -h exits zero'
     end
     $stderr.write err
-    assert_equal '', err
+    assert_empty err
     assert_match /^usage:/, out
   end
 
   def test_raw_stdin
+    skip "Waiting unitl #4534 is implemented"
+
     out, err = capture_subprocess_io do
       r,w = IO.pipe
       wpid = fork do
@@ -30,7 +31,7 @@ class TestArvPut < Minitest::Test
         w << 'foo'
       end
       w.close
-      assert_equal true, arv_put('--raw', {in: r})
+      assert arv_put('--raw', {in: r})
       r.close
       Process.waitpid wpid
     end
@@ -40,8 +41,10 @@ class TestArvPut < Minitest::Test
   end
 
   def test_raw_file
+    skip "Waiting unitl #4534 is implemented"
+
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--raw', './tmp/foo')
+      assert arv_put('--raw', './tmp/foo')
     end
     $stderr.write err
     assert_match '', err
@@ -49,8 +52,10 @@ class TestArvPut < Minitest::Test
   end
 
   def test_raw_empty_file
+    skip "Waiting unitl #4534 is implemented"
+
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--raw', './tmp/empty_file')
+      assert arv_put('--raw', './tmp/empty_file')
     end
     $stderr.write err
     assert_match '', err
@@ -63,7 +68,7 @@ class TestArvPut < Minitest::Test
                    'arv-put --filename refuses directory')
     end
     assert_match /^usage:.*error:/m, err
-    assert_equal '', out
+    assert_empty out
   end
 
   def test_filename_arg_with_multiple_files
@@ -74,21 +79,25 @@ class TestArvPut < Minitest::Test
                    'arv-put --filename refuses directory')
     end
     assert_match /^usage:.*error:/m, err
-    assert_equal '', out
+    assert_empty out
   end
 
   def test_filename_arg_with_empty_file
+    skip "Waiting unitl #4534 is implemented"
+
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--filename', 'foo', './tmp/empty_file')
+      assert arv_put('--filename', 'foo', './tmp/empty_file')
     end
     $stderr.write err
     assert_match '', err
-    assert_equal "aa4f15cbf013142a7d98b1e273f9c661+45\n", out
+    assert match_collection_uuid(out)
   end
 
   def test_as_stream
+    skip "Waiting unitl #4534 is implemented"
+
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--as-stream', './tmp/foo')
+      assert arv_put('--as-stream', './tmp/foo')
     end
     $stderr.write err
     assert_match '', err
@@ -96,20 +105,24 @@ class TestArvPut < Minitest::Test
   end
 
   def test_progress
+    skip "Waiting unitl #4534 is implemented"
+
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--manifest', '--progress', './tmp/foo')
+      assert arv_put('--manifest', '--progress', './tmp/foo')
     end
     assert_match /%/, err
-    assert_equal foo_manifest_locator+"\n", out
+    assert match_collection_uuid(out)
   end
 
   def test_batch_progress
+    skip "Waiting unitl #4534 is implemented"
+
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--manifest', '--batch-progress', './tmp/foo')
+      assert arv_put('--manifest', '--batch-progress', './tmp/foo')
     end
     assert_match /: 0 written 3 total/, err
     assert_match /: 3 written 3 total/, err
-    assert_equal foo_manifest_locator+"\n", out
+    assert match_collection_uuid(out)
   end
 
   def test_progress_and_batch_progress
@@ -119,18 +132,24 @@ class TestArvPut < Minitest::Test
                    'arv-put --progress --batch-progress is contradictory')
     end
     assert_match /^usage:.*error:/m, err
-    assert_equal '', out
+    assert_empty out
   end
 
   def test_read_from_implicit_stdin
+    skip "Waiting unitl #4534 is implemented"
+
     test_read_from_stdin(specify_stdin_as='--manifest')
   end
 
   def test_read_from_dev_stdin
+    skip "Waiting unitl #4534 is implemented"
+
     test_read_from_stdin(specify_stdin_as='/dev/stdin')
   end
 
   def test_read_from_stdin(specify_stdin_as='-')
+    skip "Waiting unitl #4534 is implemented"
+
     out, err = capture_subprocess_io do
       r,w = IO.pipe
       wpid = fork do
@@ -138,27 +157,33 @@ class TestArvPut < Minitest::Test
         w << 'foo'
       end
       w.close
-      assert_equal true, arv_put('--filename', 'foo', specify_stdin_as,
+      assert arv_put('--filename', 'foo', specify_stdin_as,
                                  { in: r })
       r.close
       Process.waitpid wpid
     end
     $stderr.write err
     assert_match '', err
-    assert_equal foo_manifest_locator+"\n", out
+    assert match_collection_uuid(out)
   end
 
   def test_read_from_implicit_stdin_implicit_manifest
+    skip "Waiting unitl #4534 is implemented"
+
     test_read_from_stdin_implicit_manifest(specify_stdin_as=nil,
                                            expect_filename='stdin')
   end
 
   def test_read_from_dev_stdin_implicit_manifest
+    skip "Waiting unitl #4534 is implemented"
+
     test_read_from_stdin_implicit_manifest(specify_stdin_as='/dev/stdin')
   end
 
   def test_read_from_stdin_implicit_manifest(specify_stdin_as='-',
                                              expect_filename=nil)
+    skip "Waiting unitl #4534 is implemented"
+
     expect_filename = expect_filename || specify_stdin_as.split('/').last
     out, err = capture_subprocess_io do
       r,w = IO.pipe
@@ -169,14 +194,13 @@ class TestArvPut < Minitest::Test
       w.close
       args = []
       args.push specify_stdin_as if specify_stdin_as
-      assert_equal true, arv_put(*args, { in: r })
+      assert arv_put(*args, { in: r })
       r.close
       Process.waitpid wpid
     end
     $stderr.write err
     assert_match '', err
-    assert_equal(foo_manifest_locator(expect_filename)+"\n",
-                 out)
+    assert match_collection_uuid(out)
   end
 
   protected
@@ -192,4 +216,8 @@ class TestArvPut < Minitest::Test
     Digest::MD5.hexdigest(foo_manifest(filename)) +
       "+#{foo_manifest(filename).length}"
   end
+
+  def match_collection_uuid(uuid)
+    /^([0-9a-z]{5}-4zz18-[0-9a-z]{15})?$/.match(uuid)
+  end
 end