X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/85783390943d70fc9fcdaee2dc8a72e4236301c2..4470ba26b332cb92d347af00cdb26c716b1a6953:/sdk/cli/test/test_arv-get.rb diff --git a/sdk/cli/test/test_arv-get.rb b/sdk/cli/test/test_arv-get.rb index 52a9cd1552..67dd399a24 100644 --- a/sdk/cli/test/test_arv-get.rb +++ b/sdk/cli/test/test_arv-get.rb @@ -30,10 +30,14 @@ class TestArvGet < Minitest::Test end def test_file_to_dev_stdout + skip "Waiting unitl #4534 is implemented" + test_file_to_stdout('/dev/stdout') end def test_file_to_stdout(specify_stdout_as='-') + skip "Waiting unitl #4534 is implemented" + out, err = capture_subprocess_io do assert_arv_get @@foo_manifest_locator + '/foo', specify_stdout_as end @@ -42,6 +46,8 @@ class TestArvGet < Minitest::Test end def test_file_to_file + skip "Waiting unitl #4534 is implemented" + remove_tmp_foo out, err = capture_subprocess_io do assert_arv_get @@foo_manifest_locator + '/foo', 'tmp/foo' @@ -51,12 +57,72 @@ class TestArvGet < Minitest::Test assert_equal 'foo', IO.read('tmp/foo') end + def test_file_to_file_no_overwrite_file + skip "Waiting unitl #4534 is implemented" + 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 + skip "Waiting unitl #4534 is implemented" + 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 + skip "Waiting unitl #4534 is implemented" + + 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 + skip "Waiting unitl #4534 is implemented" + + 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 + skip "Waiting unitl #4534 is implemented" + + 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,15 +141,29 @@ class TestArvGet < Minitest::Test assert_match /^usage:/, err end + def test_nonexistent_block + skip "Waiting unitl #4534 is implemented" + + out, err = capture_subprocess_io do + assert_arv_get false, 'f1554a91e925d6213ce7c3103c5110c6' + end + assert_equal '', out + assert_match /Error:/, err + end + def test_nonexistent_manifest + skip "Waiting unitl #4534 is implemented" + out, err = capture_subprocess_io do assert_arv_get false, 'f1554a91e925d6213ce7c3103c5110c6/', 'tmp/' end assert_equal '', out - assert_match /^ERROR:/, err + assert_match /Error:/, err end def test_manifest_root_to_dir + skip "Waiting unitl #4534 is implemented" + remove_tmp_foo out, err = capture_subprocess_io do assert_arv_get '-r', @@foo_manifest_locator + '/', 'tmp/' @@ -94,6 +174,8 @@ class TestArvGet < Minitest::Test end def test_manifest_root_to_dir_noslash + skip "Waiting unitl #4534 is implemented" + remove_tmp_foo out, err = capture_subprocess_io do assert_arv_get '-r', @@foo_manifest_locator + '/', 'tmp' @@ -104,6 +186,8 @@ class TestArvGet < Minitest::Test end def test_display_md5sum + skip "Waiting unitl #4534 is implemented" + remove_tmp_foo out, err = capture_subprocess_io do assert_arv_get '-r', '--md5sum', @@foo_manifest_locator + '/', 'tmp/' @@ -114,6 +198,8 @@ class TestArvGet < Minitest::Test end def test_md5sum_nowrite + skip "Waiting unitl #4534 is implemented" + remove_tmp_foo out, err = capture_subprocess_io do assert_arv_get '-n', '--md5sum', @@foo_manifest_locator + '/', 'tmp/' @@ -124,6 +210,8 @@ class TestArvGet < Minitest::Test end def test_sha1_nowrite + skip "Waiting unitl #4534 is implemented" + remove_tmp_foo out, err = capture_subprocess_io do assert_arv_get '-n', '-r', '--hash', 'sha1', @@foo_manifest_locator+'/', 'tmp/' @@ -134,16 +222,22 @@ class TestArvGet < Minitest::Test end def test_block_to_file + skip "Waiting unitl #4534 is implemented" + remove_tmp_foo out, err = capture_subprocess_io do assert_arv_get @@foo_manifest_locator, 'tmp/foo' end assert_equal '', err assert_equal '', out - assert_equal foo_manifest, IO.read('tmp/foo') + + digest = Digest::MD5.hexdigest('foo') + !(IO.read('tmp/foo')).gsub!( /^(. #{digest}+3)(.*)( 0:3:foo)$/).nil? end def test_create_directory_tree + skip "Waiting unitl #4534 is implemented" + `rm -rf ./tmp/arv-get-test/` Dir.mkdir './tmp/arv-get-test' out, err = capture_subprocess_io do @@ -155,6 +249,8 @@ class TestArvGet < Minitest::Test end def test_create_partial_directory_tree + skip "Waiting unitl #4534 is implemented" + `rm -rf ./tmp/arv-get-test/` Dir.mkdir './tmp/arv-get-test' out, err = capture_subprocess_io do @@ -180,10 +276,6 @@ class TestArvGet < Minitest::Test "should exit #{if expect then 0 else 'non-zero' end}") end - def foo_manifest - ". #{Digest::MD5.hexdigest('foo')}+3 0:3:foo\n" - end - def remove_tmp_foo begin File.unlink('tmp/foo')