X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8893e8cf0dfd542508e9e45d715ee0165b249bd8..646ea4328be842f4baa194205618c01910ec49db:/sdk/ruby/test/test_collection.rb?ds=sidebyside diff --git a/sdk/ruby/test/test_collection.rb b/sdk/ruby/test/test_collection.rb index e96054bfbd..288fd263fa 100644 --- a/sdk/ruby/test/test_collection.rb +++ b/sdk/ruby/test/test_collection.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: Apache-2.0 + require "arvados/collection" require "minitest/autorun" require "sdk_fixtures" @@ -223,13 +227,17 @@ class CollectionTest < Minitest::Test assert_equal(expected.join(""), coll.manifest_text) end - def test_copy_stream_over_file_raises_ENOTDIR + def test_copy_stream_over_file_raises_ENOTDIR(source="./s1", target="./f2") coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S) assert_raises(Errno::ENOTDIR) do - coll.cp_r("./s1", "./f2") + coll.cp_r(source, target) end end + def test_copy_file_under_file_raises_ENOTDIR + test_copy_stream_over_file_raises_ENOTDIR("./f1", "./f2/newfile") + end + def test_copy_stream_over_nonempty_stream_merges_and_overwrites blocks = random_blocks(3, 9) manifest_a = @@ -323,6 +331,20 @@ class CollectionTest < Minitest::Test assert_equal(expect_lines.join(""), coll.manifest_text) end + def test_copy_file_into_new_stream_with_implicit_filename + coll = Arv::Collection.new(SIMPLEST_MANIFEST) + coll.cp_r("./simple.txt", "./new/") + assert_equal(SIMPLEST_MANIFEST + SIMPLEST_MANIFEST.sub(". ", "./new "), + coll.manifest_text) + end + + def test_copy_file_into_new_stream_with_explicit_filename + coll = Arv::Collection.new(SIMPLEST_MANIFEST) + coll.cp_r("./simple.txt", "./new/newfile.txt") + new_line = SIMPLEST_MANIFEST.sub(". ", "./new ").sub(":simple", ":newfile") + assert_equal(SIMPLEST_MANIFEST + new_line, coll.manifest_text) + end + def test_copy_stream_contents_into_root coll = Arv::Collection.new(TWO_BY_TWO_MANIFEST_S) coll.cp_r("./s1/", ".") @@ -363,6 +385,16 @@ class CollectionTest < Minitest::Test dst_coll.manifest_text) end + def test_copy_root_into_empty_collection + block = random_block(8) + src_coll = Arv::Collection.new(". #{block} 0:8:f1\n") + dst_coll = Arv::Collection.new() + dst_coll.cp_r("./", ".", src_coll) + assert_equal(". %s 0:8:f1\n" % + [block], + dst_coll.manifest_text) + end + def test_copy_empty_source_path_raises_ArgumentError(src="", dst="./s1") coll = Arv::Collection.new(SIMPLEST_MANIFEST) assert_raises(ArgumentError) do