зеркало из
1
0
Форкнуть 0

change true to nil on true or exception results, updated tests

This commit is contained in:
Troy Howard 2012-10-23 21:20:05 -07:00
Родитель be77b30c20
Коммит 4a36e6c708
22 изменённых файлов: 106 добавлений и 85 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -2,4 +2,5 @@
tags
/pkg
/doc
Gemfile.lock
Gemfile.lock
.DS_Store

Просмотреть файл

@ -373,8 +373,8 @@ module Azure
def _modify_message(method, path, sequence_number, lock_token)
uri = message_uri(path, sequence_number, lock_token)
response = call(method, uri)
response.success?
call(method, uri)
nil
end
def _send_message(path, message)
@ -396,8 +396,8 @@ module Azure
headers["Content-Type"] = content_type
response = call(:post, messages_uri(path), message.body, headers)
response.success?
call(:post, messages_uri(path), message.body, headers)
nil
end
def _read_delete_message(path, timeout=60)
@ -497,8 +497,8 @@ module Azure
end
def delete_resource_entry(resource, *p)
response = call(:delete, self.send("#{resource.to_s}_uri", *p))
response.success?
call(:delete, self.send("#{resource.to_s}_uri", *p))
nil
end
def resource_entry(resource, *p)

Просмотреть файл

@ -114,8 +114,8 @@ module Azure
#
# Returns true on success
def delete_container(name)
response = call(:delete, container_uri(name))
response.success?
call(:delete, container_uri(name))
nil
end
# Public: Returns all properties and metadata on the container.
@ -215,8 +215,8 @@ module Azure
add_metadata_to_headers(metadata, headers) if metadata
response = call(:put, container_uri(name, {"comp"=>"metadata"}), nil, headers)
response.success?
call(:put, container_uri(name, {"comp"=>"metadata"}), nil, headers)
nil
end
# Public: Get a list of Blobs from the server
@ -566,9 +566,8 @@ module Azure
end
body = Serialization.block_list_to_xml(block_list)
response = call(:put, uri, body, headers)
response.success?
call(:put, uri, body, headers)
nil
end
# Public: Retrieves the list of blocks that have been uploaded as part of a block blob.
@ -778,8 +777,8 @@ module Azure
headers["x-ms-blob-sequence-number"] = options[:sequence_number].to_s if options[:sequence_number]
end
response = call(:put, uri, nil, headers)
response.success?
call(:put, uri, nil, headers)
nil
end
# Public: Sets metadata headers on the blob.
@ -798,8 +797,8 @@ module Azure
add_metadata_to_headers(metadata, headers) if metadata
response = call(:put, uri, nil, headers)
response.success?
call(:put, uri, nil, headers)
nil
end
# Public: Reads or downloads a blob from the system, including its metadata and properties.
@ -855,8 +854,8 @@ module Azure
headers = {}
headers["x-ms-delete-snapshots"] = delete_snapshots.to_s if delete_snapshots && snapshot == nil
response = call(:delete, uri, nil, headers)
response.success?
call(:delete, uri, nil, headers)
nil
end
# Public: Creates a snapshot of a blob.
@ -1005,7 +1004,7 @@ module Azure
headers["x-ms-proposed-lease-id"] = proposed_lease_id if proposed_lease_id
response = call(:put, uri, nil, headers)
response.headers["x-ms-lease-id"] if response.success?
response.headers["x-ms-lease-id"]
end
# Public: Renews the lease. The lease can be renewed if the lease ID specified on the request matches that
@ -1028,7 +1027,7 @@ module Azure
headers["x-ms-lease-id"] = lease
response = call(:put, uri, nil, headers)
response.headers["x-ms-lease-id"] if response.success?
response.headers["x-ms-lease-id"]
end
# Public: Releases the lease. The lease may be released if the lease ID specified on the request matches that
@ -1049,8 +1048,8 @@ module Azure
headers["x-ms-lease-action"] = "release"
headers["x-ms-lease-id"] = lease
response = call(:put, uri, nil, headers)
response.success?
call(:put, uri, nil, headers)
nil
end
# Public: Breaks the lease, if the blob has an active lease. Once a lease is broken, it cannot be renewed. Any

Просмотреть файл

@ -93,8 +93,8 @@ module Azure
# Returns true on success
def clear_messages(queue_name)
uri = messages_uri(queue_name)
response = call(:delete, uri)
response.success?
call(:delete, uri)
nil
end
# Public: Creates a new queue under the storage account.
@ -109,8 +109,8 @@ module Azure
uri = queue_uri(queue_name)
headers = {}
add_metadata_to_headers(metadata || {}, headers)
response = call(:put, uri, nil, headers)
response.success?
call(:put, uri, nil, headers)
nil
end
# Public: Deletes a queue.
@ -122,8 +122,8 @@ module Azure
# Returns true on success
def delete_queue(queue_name)
uri = queue_uri(queue_name)
response = call(:delete, uri)
response.success?
call(:delete, uri)
nil
end
# Public: Returns queue properties, including user-defined metadata.
@ -161,8 +161,8 @@ module Azure
headers ={}
add_metadata_to_headers(metadata || {}, headers)
response = call(:put, uri, nil, headers)
response.success?
call(:put, uri, nil, headers)
nil
end
# Public: Gets the access control list (ACL) for the queue.
@ -193,8 +193,8 @@ module Azure
body = nil
body = Serialization.signed_identifiers_to_xml(signed_identifiers) if signed_identifiers && signed_identifiers.length > 0
response = call(:put, uri, body, {})
response.success?
call(:put, uri, body, {})
nil
end
# Public: Adds a message to the queue and optionally sets a visibility timeout for the message.
@ -225,8 +225,8 @@ module Azure
uri = messages_uri(queue_name, query)
body = Serialization.message_to_xml(message_text)
response = call(:post, uri, body, {})
response.success?
call(:post, uri, body, {})
nil
end
# Public: Deletes a specified message from the queue.
@ -280,8 +280,8 @@ module Azure
def delete_message(queue_name, message_id, pop_receipt)
uri = message_uri(queue_name, message_id, { "popreceipt" => pop_receipt })
response = call(:delete, uri)
response.success?
call(:delete, uri)
nil
end
# Public: Retrieves one or more messages from the front of the queue, without changing the message visibility.

Просмотреть файл

@ -62,8 +62,8 @@ module Azure
body = Serialization.service_properties_to_xml service_properties
uri = service_properties_uri
response = call(:put, uri, body)
response.success?
call(:put, uri, body)
nil
end
# Public: Generate the URI for the service properties

Просмотреть файл

@ -39,8 +39,8 @@ module Azure
# Returns true on success
def create_table(table_name)
body = Azure::Storage::Table::Serialization.hash_to_entry_xml({"TableName" => table_name}).to_xml
response = call(:post, collection_uri, body)
response.success?
call(:post, collection_uri, body)
nil
end
# Public: Deletes the specified table and any data it contains.
@ -51,8 +51,8 @@ module Azure
#
# Returns true on success
def delete_table(table_name)
response = call(:delete, table_uri(table_name))
response.success?
call(:delete, table_uri(table_name))
nil
end
# Public: Gets the table.
@ -123,8 +123,8 @@ module Azure
body = nil
body = Azure::Storage::Table::Serialization.signed_identifiers_to_xml signed_identifiers if signed_identifiers && signed_identifiers.length > 0
response = call(:put, uri, body, {})
response.success?
call(:put, uri, body, {})
nil
end
# Public: Inserts new entity to the table.
@ -301,8 +301,8 @@ module Azure
#
# Returns true on success
def delete_entity(table_name, partition_key, row_key, if_match=nil)
response = call(:delete, entities_uri(table_name, partition_key, row_key), nil, {"If-Match"=> if_match || "*"})
response.success?
call(:delete, entities_uri(table_name, partition_key, row_key), nil, {"If-Match"=> if_match || "*"})
nil
end
# Public: Executes a batch of operations.

Просмотреть файл

@ -30,7 +30,8 @@ describe Azure::Storage::Blob::BlobService do
}
it 'sets and gets metadata for a blob' do
assert subject.set_blob_metadata container_name, blob_name, metadata
result = subject.set_blob_metadata container_name, blob_name, metadata
result.must_be_nil
blob = subject.get_blob_metadata container_name, blob_name
metadata.each { |k,v|

Просмотреть файл

@ -36,7 +36,8 @@ describe Azure::Storage::Blob::BlobService do
}}
it 'sets and gets properties for a blob' do
assert subject.set_blob_properties container_name, blob_name, options
result = subject.set_blob_properties container_name, blob_name, options
result.must_be_nil
blob = subject.get_blob_properties container_name, blob_name
blob.properties.content_type.must_equal options[:blob_content_type]
blob.properties.content_encoding.must_equal options[:blob_content_encoding]

Просмотреть файл

@ -100,7 +100,8 @@ describe Azure::Storage::Blob::BlobService do
end
# commit blocks
assert subject.commit_blob_blocks container_name, blob_name, blocklist
result = subject.commit_blob_blocks container_name, blob_name, blocklist
result.must_be_nil
blob, returned_content = subject.get_blob container_name, blob_name
blob.properties.content_length.must_equal (content.length * 2)
@ -116,7 +117,8 @@ describe Azure::Storage::Blob::BlobService do
subject.create_blob_block container_name, blob_name, blocklist[1][0], content
# two committed blocks, two uncommitted blocks
assert subject.commit_blob_blocks container_name, blob_name, blocklist.slice(0..1)
result = subject.commit_blob_blocks container_name, blob_name, blocklist.slice(0..1)
result.must_be_nil
subject.create_blob_block container_name, blob_name, blocklist[2][0], content
subject.create_blob_block container_name, blob_name, blocklist[3][0], content
@ -216,7 +218,8 @@ describe Azure::Storage::Blob::BlobService do
it 'lists blocks for the blob snapshot' do
snapshot = subject.create_blob_snapshot container_name, blob_name
assert subject.commit_blob_blocks container_name, blob_name, blocklist
result = subject.commit_blob_blocks container_name, blob_name, blocklist
result.must_be_nil
result = subject.list_blob_blocks container_name, blob_name
committed = result[:committed]

Просмотреть файл

@ -27,7 +27,8 @@ describe Azure::Storage::Blob::BlobService do
}
it 'sets and gets custom metadata for the container' do
assert subject.set_container_metadata container_name, metadata
result = subject.set_container_metadata container_name, metadata
result.must_be_nil
container = subject.get_container_metadata container_name
container.wont_be_nil
container.name.must_equal container_name

Просмотреть файл

@ -26,7 +26,8 @@ describe Azure::Storage::Blob::BlobService do
}
it 'deletes the container' do
assert subject.delete_container container_name
result = subject.delete_container container_name
result.must_be_nil
end
it 'errors if the container does not exist' do

Просмотреть файл

@ -27,7 +27,8 @@ describe Azure::Storage::Queue::QueueService do
after { QueueNameHelper.clean }
it "clears the queue" do
assert subject.clear_messages queue_name
result = subject.clear_messages queue_name
result.must_be_nil
result = subject.peek_messages queue_name
result.must_be_empty
end

Просмотреть файл

@ -25,7 +25,9 @@ describe Azure::Storage::Queue::QueueService do
after { QueueNameHelper.clean }
it "creates a message in the specified queue and returns true on success" do
assert subject.create_message(queue_name, message_text), "create_message failed"
result = subject.create_message(queue_name, message_text)
result.must_be_nil
result = subject.peek_messages queue_name
result.wont_be_nil
result.wont_be_empty
@ -38,8 +40,9 @@ describe Azure::Storage::Queue::QueueService do
let(:message_ttl) { 600 }
it "the :visibility_timeout option causes the message to be invisible for a period of time" do
assert subject.create_message(queue_name, message_text, { :visibility_timeout=> visibility_timeout }), "create_message failed"
result = subject.create_message(queue_name, message_text, { :visibility_timeout=> visibility_timeout })
result.must_be_nil
result = subject.peek_messages queue_name
result.length.must_equal 0
sleep(visibility_timeout)
@ -51,7 +54,9 @@ describe Azure::Storage::Queue::QueueService do
end
it "the :message_ttl option modifies the expiration_date of the message" do
assert subject.create_message(queue_name, message_text, { :message_ttl=> message_ttl }), "create_message failed"
result = subject.create_message(queue_name, message_text, { :message_ttl=> message_ttl })
result.must_be_nil
result = subject.peek_messages queue_name
result.wont_be_nil
result.wont_be_empty

Просмотреть файл

@ -24,7 +24,8 @@ describe Azure::Storage::Queue::QueueService do
after { QueueNameHelper.clean }
it "creates a queue with a valid name" do
assert subject.create_queue(queue_name)
result = subject.create_queue(queue_name)
result.must_be_nil
end
it "errors on an invalid queue name" do

Просмотреть файл

@ -31,8 +31,9 @@ describe Azure::Storage::Queue::QueueService do
messages.length.must_equal 1
message = messages.first
assert subject.delete_message queue_name, message.id, message.pop_receipt
result = subject.delete_message queue_name, message.id, message.pop_receipt
result.must_be_nil
result = subject.peek_messages queue_name
result.must_be_empty
end

Просмотреть файл

@ -24,7 +24,8 @@ describe Azure::Storage::Queue::QueueService do
after { QueueNameHelper.clean }
it "deletes a queue and returns true on success" do
assert subject.delete_queue(queue_name)
result = subject.delete_queue(queue_name)
result.must_be_nil
result = subject.list_queues
result.queues.each { |q| q.name.wont_equal queue_name }
end

Просмотреть файл

@ -26,7 +26,8 @@ describe Azure::Storage::Queue::QueueService do
after { QueueNameHelper.clean }
it 'can set and retrieve queue metadata' do
assert subject.set_queue_metadata queue_name, {"CustomMetadataProperty" => "Custom Metadata Value"}
result = subject.set_queue_metadata queue_name, {"CustomMetadataProperty" => "Custom Metadata Value"}
result.must_be_nil
message_count, metadata = subject.get_queue_metadata queue_name
message_count.must_equal 1

Просмотреть файл

@ -23,7 +23,8 @@ describe Azure::Storage::Table::TableService do
after { TableNameHelper.clean }
it "creates a table with a valid name" do
assert subject.create_table(table_name)
result = subject.create_table(table_name)
result.must_be_nil
end
it "errors on an invalid table name" do

Просмотреть файл

@ -39,7 +39,8 @@ describe Azure::Storage::Table::TableService do
after { TableNameHelper.clean }
it "deletes an entity" do
assert subject.delete_entity table_name, partition, row_key
result = subject.delete_entity table_name, partition, row_key
result.must_be_nil
end
it "errors on an invalid table name" do

Просмотреть файл

@ -24,7 +24,9 @@ describe Azure::Storage::Table::TableService do
after { TableNameHelper.clean }
it "deletes a table and returns true on success" do
assert subject.delete_table(table_name)
result = subject.delete_table(table_name)
result.must_be_nil
tables = subject.query_tables
tables.wont_include table_name
end

Просмотреть файл

@ -214,9 +214,9 @@ describe Azure::Storage::Blob::BlobService do
subject.delete_container container_name
end
it "returns true on success" do
it "returns nil on success" do
result = subject.delete_container container_name
result.must_equal true
result.must_equal nil
end
end
@ -461,9 +461,9 @@ describe Azure::Storage::Blob::BlobService do
subject.set_container_metadata container_name, container_metadata
end
it "returns true on success" do
it "returns nil on success" do
result = subject.set_container_metadata container_name, container_metadata
result.must_equal true
result.must_equal nil
end
end
@ -1002,9 +1002,9 @@ describe Azure::Storage::Blob::BlobService do
subject.commit_blob_blocks container_name, blob_name, block_list
end
it "returns true on success" do
it "returns nil on success" do
result = subject.commit_blob_blocks container_name, blob_name, block_list
result.must_equal true
result.must_equal nil
end
describe "when the options Hash is used" do
@ -1202,9 +1202,9 @@ describe Azure::Storage::Blob::BlobService do
subject.set_blob_properties container_name, blob_name
end
it "returns true on success" do
it "returns nil on success" do
result = subject.set_blob_properties container_name, blob_name
result.must_equal true
result.must_equal nil
end
describe "when the options Hash is used" do
@ -1276,9 +1276,9 @@ describe Azure::Storage::Blob::BlobService do
subject.set_blob_metadata container_name, blob_name, blob_metadata
end
it "returns true on success" do
it "returns nil on success" do
result = subject.set_blob_metadata container_name, blob_name, blob_metadata
result.must_equal true
result.must_equal nil
end
end
@ -1492,9 +1492,9 @@ describe Azure::Storage::Blob::BlobService do
subject.delete_blob container_name, blob_name
end
it "returns true on success" do
it "returns nil on success" do
result = subject.delete_blob container_name, blob_name
result.must_equal true
result.must_equal nil
end
describe "when snapshot is provided" do
@ -1822,9 +1822,9 @@ describe Azure::Storage::Blob::BlobService do
subject.release_lease container_name, blob_name, lease_id
end
it "returns true on success" do
it "returns nil on success" do
result = subject.release_lease container_name, blob_name, lease_id
result.must_equal true
result.must_equal nil
end
end
@ -1848,7 +1848,7 @@ describe Azure::Storage::Blob::BlobService do
subject.break_lease container_name, blob_name, lease_id
end
it "returns true on success" do
it "returns lease time on success" do
result = subject.break_lease container_name, blob_name, lease_id
result.must_equal lease_time
end

Просмотреть файл

@ -200,9 +200,9 @@ describe Azure::Storage::Service::StorageService do
subject.set_service_properties service_properties
end
it "returns true on success" do
it "returns nil on success" do
result = subject.set_service_properties service_properties
result.must_equal true
result.must_equal nil
end
end