Skip to content
Open
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
13 changes: 8 additions & 5 deletions google-cloud-storage/samples/acceptance/files_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ def mock_cipher.random_key

before(:each) do
bucket.create_file local_file, remote_file_name
bucket.create_file local_file, remote_file_name+"2"

set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key1, custom_context_value: custom_context_value1
set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2
Expand All @@ -349,25 +348,29 @@ def mock_cipher.random_key
let(:custom_context_value1) { "my-custom-value" }
let(:custom_context_key2) { "my-custom-key-2" }
let(:custom_context_value2) { "my-custom-value-2" }
let(:remote_file_name2) { "path/file_name_#{SecureRandom.hex}.txt" }

before(:each) do
bucket.create_file local_file, remote_file_name
bucket.create_file local_file, remote_file_name+"2"
bucket.create_file local_file, remote_file_name2

set_object_contexts bucket_name: bucket.name, file_name: remote_file_name, custom_context_key: custom_context_key1, custom_context_value: custom_context_value1
set_object_contexts bucket_name: bucket.name, file_name: remote_file_name+"2", custom_context_key: custom_context_key2, custom_context_value: custom_context_value2
set_object_contexts bucket_name: bucket.name, file_name: remote_file_name2, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2
end


it "filters out files on the basis of custom context key" do
assert_output "File: #{remote_file_name} has context key: #{custom_context_key1}\n" do
out, _err = capture_io do
list_object_contexts bucket_name: bucket.name, custom_context_key: custom_context_key1
end
assert_includes out, "#{custom_context_key1}\n"
end

it "filters out files on the basis of custom context key and value" do
assert_output "File: #{remote_file_name+"2"} has context key: #{custom_context_key2}\n" do
out, _err = capture_io do
list_object_contexts bucket_name: bucket.name, custom_context_key: custom_context_key2, custom_context_value: custom_context_value2
end
assert_includes out, "#{custom_context_key2}\n"
end
end

Expand Down