Support "arv-get {locator}/filename path/to/localdir" invocation:
[arvados.git] / sdk / cli / test / test_arv-put.rb
index 7c8fc1790c5bfd524281fbf19383cb0bb1fa10aa..5efbfda8298ec03b8dcd1e89ec27bea16ae4798d 100644 (file)
@@ -15,20 +15,12 @@ class TestArvPut < Minitest::Test
     end
   end
 
-  def test_no_args
-    out, err = capture_subprocess_io do
-      assert_equal(false, arv_put,
-                   'arv-put without args exits non-zero')
-    end
-    assert_equal '', out
-    assert_match /^usage:/, err
-  end
-
   def test_help
     out, err = capture_subprocess_io do
       assert_equal(true, arv_put('-h'),
                    'arv-put -h exits zero')
     end
+    $stderr.write err
     assert_equal '', err
     assert_match /^usage:/, out
   end
@@ -62,21 +54,30 @@ class TestArvPut < Minitest::Test
     assert_equal "aa4f15cbf013142a7d98b1e273f9c661+45\n", out
   end
 
+  def test_as_stream
+    out, err = capture_subprocess_io do
+      assert_equal true, arv_put('--as-stream', './tmp/foo')
+    end
+    $stderr.write err
+    assert_match '', err
+    assert_equal foo_manifest, out
+  end
+
   def test_progress
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--progress', './tmp/foo')
+      assert_equal true, arv_put('--manifest', '--progress', './tmp/foo')
     end
     assert_match /%/, err
-    expect_foo_manifest(out)
+    assert_equal foo_manifest_locator+"\n", out
   end
 
   def test_batch_progress
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--batch-progress', './tmp/foo')
+      assert_equal true, arv_put('--manifest', '--batch-progress', './tmp/foo')
     end
     assert_match /: 0 written 3 total/, err
     assert_match /: 3 written 3 total/, err
-    expect_foo_manifest(out)
+    assert_equal foo_manifest_locator+"\n", out
   end
 
   def test_progress_and_batch_progress
@@ -89,6 +90,10 @@ class TestArvPut < Minitest::Test
     assert_equal '', out
   end
 
+  def test_read_from_implicit_stdin
+    test_read_from_stdin(specify_stdin_as='--manifest')
+  end
+
   def test_read_from_dev_stdin
     test_read_from_stdin(specify_stdin_as='/dev/stdin')
   end
@@ -108,7 +113,7 @@ class TestArvPut < Minitest::Test
     end
     $stderr.write err
     assert_match '', err
-    expect_foo_manifest(out)
+    assert_equal foo_manifest_locator+"\n", out
   end
 
   protected
@@ -116,10 +121,11 @@ class TestArvPut < Minitest::Test
     system ['./bin/arv-put', 'arv-put'], *args
   end
 
-  def expect_foo_manifest(out)
-    expect_manifest = ". #{Digest::MD5.hexdigest('foo')}+3 0:3:foo\n"
-    assert_equal(Digest::MD5.hexdigest(expect_manifest) +
-                 "+#{expect_manifest.length}\n",
-                 out)
+  def foo_manifest
+    ". #{Digest::MD5.hexdigest('foo')}+3 0:3:foo\n"
+  end
+
+  def foo_manifest_locator
+    Digest::MD5.hexdigest(foo_manifest) + "+#{foo_manifest.length}"
   end
 end