Sha256: 0f81d7bf7849fc9c67f268b288aaef0b803e86af297d6105111c4f354422fabd

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

module CacheIncrementDecrementBehavior
  def test_increment
    @cache.write('foo', 1, :raw => true)
    assert_equal 1, @cache.read('foo').to_i
    assert_equal 2, @cache.increment('foo')
    assert_equal 2, @cache.read('foo').to_i
    assert_equal 3, @cache.increment('foo')
    assert_equal 3, @cache.read('foo').to_i
    # spymemcached will set zero as default value
    assert_equal 0, @cache.increment('bar')
  end

  def test_decrement
    @cache.write('foo', 3, :raw => true)
    assert_equal 3, @cache.read('foo').to_i
    assert_equal 2, @cache.decrement('foo')
    assert_equal 2, @cache.read('foo').to_i
    assert_equal 1, @cache.decrement('foo')
    assert_equal 1, @cache.read('foo').to_i

    # spymemcached will set zero as default value
    assert_equal 0, @cache.decrement('bar')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spymemcached_store-1.0.2-java test/cache_increment_decrement_behavior.rb
spymemcached_store-1.0.1-java test/cache_increment_decrement_behavior.rb
spymemcached_store-1.0.0 test/cache_increment_decrement_behavior.rb