Sha256: 74008d266a846467e3c2851404e13a556bdd10776c69b1443e31dc81b95758b9

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

require "integration/test_helper"

describe "Managing the blob's metadata" do
  let :container do
    Azure::Blobs.create_container(ContainerNameHelper.name)
  end

  after do
    ContainerNameHelper.clean
  end

  it "can set the metadata on blob creation (but changes key casing)" do
    blob = Azure::Blobs.create_block_blob(
      container,
      "myblob.jpg",
      Fixtures["32px-fulls-black.jpg"].to_path,
      "Key" => "Value"
    )

    blob.metadata.clear
    blob.load_metadata!
    blob.metadata["key"].must_equal "Value"
  end

  it "gets the metadata when listing blobs" do
    create_block_blob(:container => container, :metadata => {"Key" => "Value"})

    blob = Azure::Blobs.blobs(container).first
    blob.metadata["Key"].must_equal "Value"
  end

  it "force-loads the metadata when calling #load_metadata!" do
    blob = create_block_blob(:container => container, :metadata => {"name" => "Xara"})
    blob.metadata["name"] = "NotXara" # change the metadata locally
    blob.load_metadata! # it gets replaced by the metadata on the server

    blob.metadata["name"].must_equal "Xara"
  end

  it "can update the metadata on the server after you modify the hash" do
    blob = create_block_blob(:container => container)
    blob.metadata.update("name" => "Manu")

    result = blob.save_metadata!
    result.must_equal true

    blob.metadata["name"] = "NotManu"
    metadata = blob.load_metadata!
    blob.metadata["name"].must_equal "Manu"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 test/integration/blobs/manage_blob_metadata_test.rb
azure-0.1.0 test/integration/blobs/manage_blob_metadata_test.rb