Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions google-cloud-storage/acceptance/storage/bucket_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,27 @@

_(storage.bucket(hns_bucket_name)).must_be :nil?
end

describe "storage move file" do
let(:source_file) { "file_1_name_#{SecureRandom.hex}.txt" }
let(:destination_file) { "file_2_name_#{SecureRandom.hex}.txt" }
let :create_source_file do
file = StringIO.new "test"
bucket.create_file file, source_file
end
it "moves a file for bucket" do
create_source_file
bucket.move_file source_file, destination_file
refute_nil(bucket.file(destination_file))
assert_nil(bucket.file(source_file))
end

it "raises error if source and destination are having same filename" do
create_source_file
exception = assert_raises Google::Cloud::InvalidArgumentError do
bucket.move_file source_file, source_file
end
assert_equal "invalid: Source and destination object names must be different.", exception.message
end
end
end
2 changes: 1 addition & 1 deletion google-cloud-storage/lib/google/cloud/storage/bucket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3144,7 +3144,7 @@ def reload!
alias refresh! reload!

##
# Moves File from source to destination path within the same HNS-enabled bucket
# Moves File from source to destination path within the bucket.
# This Operation is being performed at server side
# @param [String] source_file The file name in existing bucket
# @param [String] destination_file The new filename to be created on bucket
Expand Down
Loading