Sha256: cd83bb84ad80fc1ff996810e5150038df214279e1f2e3c7e0658fd55e2f86744

Contents?: true

Size: 1.51 KB

Versions: 5

Compression:

Stored size: 1.51 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(['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

5 entries across 5 versions & 1 rubygems

Version Path
riak-client-2.2.0.pre1 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.1.0 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.0.0 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.0.0.rc2 spec/integration/riak/crdt_validation/map_spec.rb
riak-client-2.0.0.rc1 spec/integration/riak/crdt_validation/map_spec.rb