Sha256: e38b36051121741b2101cf3d14362e54412ef5f08a6b185ca4e019168a82259c

Contents?: true

Size: 1.49 KB

Versions: 11

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'
require 'riak'

describe 'CRDT map validation', integration: true, test_client: true do
  let(:bucket){ random_bucket 'crdt_validation' }
  let(:map){ Riak::Crdt::Map.new bucket, random_key }

  it 'deletes sets and re-add entries' do
    map.batch do |m|
      m.sets['set'].add 'X'
      m.sets['set'].add 'Y'
    end

    map.reload
    expect(map.sets['set'].include? 'Y').to be

    expect do
      map.batch do |m|
        m.sets.delete 'set'
        m.sets['set'].add 'Z'
      end
    end.to_not raise_error

    map2 = Riak::Crdt::Map.new bucket, map.key

    expect(map2.sets['set'].members).to eq ::Set.new(['Z'])
  end

  it 'deletes counters and increments counters' do
    map.counters['counter'].increment 5

    map.reload

    expect(map.counters['counter'].value).to eq 5

    map.batch do |m|
      m.counters['counter'].increment 2
      m.counters.delete 'counter'
    end

    map2 = Riak::Crdt::Map.new bucket, map.key

    expect(map2.counters['counter'].value).to eq(7).or eq(2)
  end

  it 'deletes maps containing sets and re-adds the contained sets' do
    map.batch do |m|
      m.maps['map'].sets['set'].add "X"
      m.maps['map'].sets['set'].add "Y"
    end

    map.reload
    expect(map.maps['map'].sets['set'].members).to eq ::Set.new(%w(X Y))

    map.batch do |m|
      m.maps.delete 'map'
      m.maps['map'].sets['set'].add "Z"
    end

    map2 = Riak::Crdt::Map.new bucket, map.key
    expect(map2.maps['map'].sets['set'].members).to eq ::Set.new(['Z'])
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
riak-client-2.5.0 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.4.1 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.4.0 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.4.0.pre1 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.3.2 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.3.1 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.3.0 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.2.2 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.2.1 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-noenc-1.0.0 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.2.0 spec/integration/riak/crdt_validation/map_spec.rb