Sha256: 0e1ddb9937e0a0178c7493e18d36fcc4baea59861f5c345cb2c9d8bc0a74e6f1

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require "integration/test_helper"

describe "Updating Entities" do
  after do
    TableNameHelper.clean
  end

  before do
    @table = Azure::Tables::Table.create(TableNameHelper.name)
    @entity = Azure::Tables::Entity.new(
      "PartitionKey" => "part1",
      "RowKey"       => "row1",
      "Address"      => "Mountain View",
      "FirstName"    => "John",
      "Email"        => "john@example.com"
    )
    @table.insert(@entity)
  end

  it "should be able to update the entity from the entity itself" do
    result = @entity.update(
      "PartitionKey" => "part1",
      "RowKey"       => "row1",
      "Address"      => "New York"
    )

    result.must_equal true

    @entity["Address"].must_equal "New York"
    @entity["FirstName"].must_equal nil

    # TODO: Load the Entity to check if the properties were updated.
  end

  it "fails when it tries to update a stale entity" do
    stale_entity = @entity.dup

    @entity.update(
      "PartitionKey" => "part1",
      "RowKey"       => "row1",
      "Address"      => "New York"
    )

    result = stale_entity.update(
      "PartitionKey" => "part1",
      "RowKey"       => "row1",
      "Address"      => "Chicago"
    )
    result.must_equal false

    refute stale_entity.valid?
    stale_entity.error.code.must_equal 412
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 test/integration/tables/update_entity_test.rb
azure-0.1.0 test/integration/tables/update_entity_test.rb