X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/527255236b66380bd50bda0f42e8e4bf56397386..db66ff7c2511f80f3795c388f314753064378543:/sdk/cli/test/test_arv-put.rb diff --git a/sdk/cli/test/test_arv-put.rb b/sdk/cli/test/test_arv-put.rb index 5dca976dc1..2f20e18440 100644 --- a/sdk/cli/test/test_arv-put.rb +++ b/sdk/cli/test/test_arv-put.rb @@ -3,11 +3,8 @@ require 'digest/md5' class TestArvPut < Minitest::Test def setup - begin - Dir.mkdir './tmp' - Dir.mkdir './tmp/empty_dir' - rescue Errno::EEXIST - end + begin Dir.mkdir './tmp' rescue Errno::EEXIST end + begin Dir.mkdir './tmp/empty_dir' rescue Errno::EEXIST end File.open './tmp/empty_file', 'wb' do end File.open './tmp/foo', 'wb' do |f| @@ -17,11 +14,10 @@ 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 @@ -33,7 +29,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 @@ -44,7 +40,7 @@ class TestArvPut < Minitest::Test def test_raw_file 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 @@ -53,7 +49,7 @@ class TestArvPut < Minitest::Test def test_raw_empty_file 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 @@ -66,7 +62,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 @@ -77,21 +73,21 @@ 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 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 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 @@ -100,19 +96,19 @@ class TestArvPut < Minitest::Test def test_progress 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 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 @@ -122,7 +118,7 @@ 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 @@ -141,14 +137,14 @@ 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 @@ -172,14 +168,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 @@ -195,4 +190,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