diff --git a/test/integration/storage/blob/clear_blob_pages_test.rb b/test/integration/storage/blob/clear_blob_pages_test.rb deleted file mode 100644 index bb00c70b6..000000000 --- a/test/integration/storage/blob/clear_blob_pages_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#-------------------------------------------------------------------------- -require "integration/test_helper" -require "azure/storage/blob/blob_service" - -describe Azure::Storage::Blob::BlobService do - subject { Azure::Storage::Blob::BlobService.new } - - describe '#clear_blob_pages' do - it '' do - - end - end -end diff --git a/test/integration/storage/blob/create_blob_block_test.rb b/test/integration/storage/blob/create_blob_block_test.rb deleted file mode 100644 index 548c432d8..000000000 --- a/test/integration/storage/blob/create_blob_block_test.rb +++ /dev/null @@ -1,26 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#-------------------------------------------------------------------------- -require "integration/test_helper" -require "azure/storage/blob/blob_service" - -describe Azure::Storage::Blob::BlobService do - subject { Azure::Storage::Blob::BlobService.new } - - describe '#create_blob_block' do - it '' do - - end - end -end diff --git a/test/integration/storage/blob/create_blob_snapshot_test.rb b/test/integration/storage/blob/create_blob_snapshot_test.rb index 75f33b4b4..e497aa5df 100644 --- a/test/integration/storage/blob/create_blob_snapshot_test.rb +++ b/test/integration/storage/blob/create_blob_snapshot_test.rb @@ -19,8 +19,61 @@ describe Azure::Storage::Blob::BlobService do subject { Azure::Storage::Blob::BlobService.new } describe '#create_blob_snapshot' do - it '' do - + let(:container_name) { ContainerNameHelper.name } + let(:blob_name) { "blobname" } + let(:content) { content = ""; 1024.times.each{|i| content << "@" }; content } + let(:metadata) { { "CustomMetadataProperty"=>"CustomMetadataValue" } } + let(:options) { { :blob_content_type=>"application/foo", :metadata => metadata } } + before { + subject.create_container container_name + subject.create_block_blob container_name, blob_name, content, options + } + after { TableNameHelper.clean } + + it 'errors if the container does not exist' do + assert_raises(Azure::Core::Http::HTTPError) do + subject.create_blob_snapshot ContainerNameHelper.name, blob_name + end + end + + it 'errors if the blob does not exist' do + assert_raises(Azure::Core::Http::HTTPError) do + subject.create_blob_snapshot container_name, "unknown-blob" + end + end + + it 'creates a snapshot of blob contents, metadata, and properties' do + snapshot = subject.create_blob_snapshot container_name, blob_name + + content2= "" + 1024.times.each{|i| content2 << "!" } + options2 = options.dup + options2[:metadata] = options[:metadata].dup + options2[:blob_content_type] = "application/bar" + options2[:metadata]["CustomMetadataValue1"] = "NewMetadata" + subject.create_block_blob container_name, blob_name, content2, options2 + + # content/properties/metadata in blob is new version + blob, returned_content = subject.get_blob container_name, blob_name, 0, 511 + returned_content.length.must_equal 512 + returned_content.must_equal content2[0..511] + blob.properties.content_type.must_equal options2[:blob_content_type] + options2[:metadata].each { |k,v| + blob.metadata.must_include k.downcase + blob.metadata[k.downcase].must_equal v + } + + # content/properties/metadata in snapshot is old version + blob, returned_content = subject.get_blob container_name, blob_name, 0, 511, snapshot + + returned_content.length.must_equal 512 + returned_content.must_equal content[0..511] + blob.properties.content_type.must_equal options[:blob_content_type] + options[:metadata].each { |k,v| + blob.metadata.must_include k.downcase + blob.metadata[k.downcase].must_equal v + } + end end end diff --git a/test/integration/storage/blob/create_block_blob_test.rb b/test/integration/storage/blob/create_block_blob_test.rb index c6c218c2a..6febfe7f7 100644 --- a/test/integration/storage/blob/create_block_blob_test.rb +++ b/test/integration/storage/blob/create_block_blob_test.rb @@ -17,16 +17,15 @@ require "azure/storage/blob/blob_service" describe Azure::Storage::Blob::BlobService do subject { Azure::Storage::Blob::BlobService.new } + let(:container_name) { ContainerNameHelper.name } + let(:blob_name) { "blobname" } + let(:content) { content = ""; 512.times.each{|i| content << "@" }; content } + before { + subject.create_container container_name + } + after { TableNameHelper.clean } describe '#create_block_blob' do - let(:container_name) { ContainerNameHelper.name } - let(:blob_name) { "blobname" } - let(:content) { content = ""; 512.times.each{|i| content << "@" }; content } - before { - subject.create_container container_name - } - after { TableNameHelper.clean } - it 'creates a page blob' do blob = subject.create_block_blob container_name, blob_name, content blob.name.must_equal blob_name @@ -59,4 +58,21 @@ describe Azure::Storage::Blob::BlobService do end end end + + describe '#create_blob_block' do + require 'base64' + let(:blockid) { Base64.strict_encode64("anyblockid") } + #before { subject.create_block_blob container_name, blob_name, content } + + it 'creates a block as part of a block blob' do + subject.create_blob_block container_name, blob_name, blockid, content + + # verify + block_list = subject.list_blob_blocks container_name, blob_name + block = block_list[:uncommitted][0] + block.type.must_equal :uncommitted + block.size.must_equal 512 + block.name.must_equal blockid + end + end end