Clean up tests with "assert_tag" method, remove non-working test. Fixes #1510.
[arvados.git] / sdk / cli / test / test_arv-get.rb
index 52a9cd15521f3beae140d82132bf7d82118af405..3d378e740c10f476df1d76a0f397276cd06f1fc6 100644 (file)
@@ -51,12 +51,64 @@ class TestArvGet < Minitest::Test
     assert_equal 'foo', IO.read('tmp/foo')
   end
 
+  def test_file_to_file_no_overwrite_file
+    File.open './tmp/foo', 'wb' do |f|
+      f.write 'baz'
+    end
+    out, err = capture_subprocess_io do
+      assert_arv_get false, @@foo_manifest_locator + '/foo', 'tmp/foo'
+    end
+    assert_match /^ERROR:/, err
+    assert_equal '', out
+    assert_equal 'baz', IO.read('tmp/foo')
+  end
+
+  def test_file_to_file_no_overwrite_file_in_dir
+    File.open './tmp/foo', 'wb' do |f|
+      f.write 'baz'
+    end
+    out, err = capture_subprocess_io do
+      assert_arv_get false, @@foo_manifest_locator + '/', 'tmp/'
+    end
+    assert_match /^ERROR:/, err
+    assert_equal '', out
+    assert_equal 'baz', IO.read('tmp/foo')
+  end
+
+  def test_file_to_file_force_overwrite
+    File.open './tmp/foo', 'wb' do |f|
+      f.write 'baz'
+    end
+    assert_equal 'baz', IO.read('tmp/foo')
+    out, err = capture_subprocess_io do
+      assert_arv_get '-f', @@foo_manifest_locator + '/', 'tmp/'
+    end
+    assert_match '', err
+    assert_equal '', out
+    assert_equal 'foo', IO.read('tmp/foo')
+  end
+
+  def test_file_to_file_skip_existing
+    File.open './tmp/foo', 'wb' do |f|
+      f.write 'baz'
+    end
+    assert_equal 'baz', IO.read('tmp/foo')
+    out, err = capture_subprocess_io do
+      assert_arv_get '--skip-existing', @@foo_manifest_locator + '/', 'tmp/'
+    end
+    assert_match '', err
+    assert_equal '', out
+    assert_equal 'baz', IO.read('tmp/foo')
+  end
+
   def test_file_to_dir
+    remove_tmp_foo
     out, err = capture_subprocess_io do
-      assert_arv_get false, @@foo_manifest_locator + '/foo', 'tmp/'
+      assert_arv_get @@foo_manifest_locator + '/foo', 'tmp/'
     end
+    assert_equal '', err
     assert_equal '', out
-    assert_match /^usage:/, err
+    assert_equal 'foo', IO.read('tmp/foo')
   end
 
   def test_dir_to_file
@@ -75,6 +127,14 @@ class TestArvGet < Minitest::Test
     assert_match /^usage:/, err
   end
 
+  def test_nonexistent_block
+    out, err = capture_subprocess_io do
+      assert_arv_get false, 'f1554a91e925d6213ce7c3103c5110c6'
+    end
+    assert_equal '', out
+    assert_match /^ERROR:/, err
+  end
+
   def test_nonexistent_manifest
     out, err = capture_subprocess_io do
       assert_arv_get false, 'f1554a91e925d6213ce7c3103c5110c6/', 'tmp/'