mock_redis 0.31.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2870385004370b0471f3cf495184d8e11f138e0cb13b9bef9bd43ed7ce2b35ff
4
- data.tar.gz: 75475cf000d2075ad2565440aea2521fa1034248726b5070ff149d9518c00c3a
3
+ metadata.gz: b9f945150c69e6ff81838d4e029f1620ade56e9da6c3cb2ed0550cd61060335a
4
+ data.tar.gz: fbd58f70dbf78b770a6d3e04351771a1d94a7cac87afbff95213c92bceb16eaa
5
5
  SHA512:
6
- metadata.gz: 6e6f75b19c46fd81ef553dfe1af1f32b2dceb13e4b660835cd58b1760fa8445c09c2ef26bf67cf64adcf87e196de24798333350e0a07ca0fac39939e296659e4
7
- data.tar.gz: 77c2c5fc3f67f654d402161541b1527c6779859a0ec6e61a5fb6048b7abfcab50728ba2c25617a2adf303b22a23e662a8f2ee7236085db02682e0e8ca690438a
6
+ metadata.gz: 9320958fc6e3360f26317dfcb47747bf8d39d626d54c0297cece31b9521fc4ad991acdccf885428d05f8b82765cfec12a37af4de33473f4106c7e3eb4e9c2b69
7
+ data.tar.gz: 05c04acff0f82500f114a868ed40aef95fc115e367ed94008075ddd90de5550dd939ca12215ffb3c88021a6aeff18cd3f9ff51dfabcc3f14244b40465d6184f0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # MockRedis Changelog
2
2
 
3
+ ### 0.32.0
4
+
5
+ * Add support for `psetex`
6
+
3
7
  ### 0.31.0
4
8
 
5
9
  * Allow `ping` to take argument
@@ -328,6 +328,16 @@ class MockRedis
328
328
  end
329
329
  end
330
330
 
331
+ def psetex(key, milliseconds, value)
332
+ if milliseconds <= 0
333
+ raise Redis::CommandError, 'ERR invalid expire time in psetex'
334
+ else
335
+ set(key, value)
336
+ pexpire(key, milliseconds)
337
+ 'OK'
338
+ end
339
+ end
340
+
331
341
  def setnx(key, value)
332
342
  if exists?(key)
333
343
  false
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  class MockRedis
5
- VERSION = '0.31.0'
5
+ VERSION = '0.32.0'
6
6
  end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe '#psetex(key, miliseconds, value)' do
4
+ before { @key = 'mock-redis-test:setex' }
5
+
6
+ it "responds with 'OK'" do
7
+ @redises.psetex(@key, 10, 'value').should == 'OK'
8
+ end
9
+
10
+ it 'sets the value' do
11
+ @redises.psetex(@key, 10_000, 'value')
12
+ @redises.get(@key).should == 'value'
13
+ end
14
+
15
+ it 'sets the expiration time' do
16
+ @redises.psetex(@key, 10_000, 'value')
17
+
18
+ # no guarantee these are the same
19
+ @redises.real.ttl(@key).should > 0
20
+ @redises.mock.ttl(@key).should > 0
21
+ end
22
+
23
+ it 'converts time correctly' do
24
+ @redises.psetex(@key, 10_000_000, 'value')
25
+
26
+ @redises.mock.ttl(@key).should > 9_000
27
+ end
28
+
29
+ context 'when expiration time is zero' do
30
+ it 'raises Redis::CommandError' do
31
+ expect do
32
+ @redises.psetex(@key, 0, 'value')
33
+ end.to raise_error(Redis::CommandError, 'ERR invalid expire time in psetex')
34
+ end
35
+ end
36
+
37
+ context 'when expiration time is negative' do
38
+ it 'raises Redis::CommandError' do
39
+ expect do
40
+ @redises.psetex(@key, -2, 'value')
41
+ end.to raise_error(Redis::CommandError, 'ERR invalid expire time in psetex')
42
+ end
43
+ end
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mock_redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-10 00:00:00.000000000 Z
12
+ date: 2022-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby2_keywords
@@ -211,6 +211,7 @@ files:
211
211
  - spec/commands/pexpireat_spec.rb
212
212
  - spec/commands/ping_spec.rb
213
213
  - spec/commands/pipelined_spec.rb
214
+ - spec/commands/psetex_spec.rb
214
215
  - spec/commands/pttl_spec.rb
215
216
  - spec/commands/quit_spec.rb
216
217
  - spec/commands/randomkey_spec.rb
@@ -397,6 +398,7 @@ test_files:
397
398
  - spec/commands/pexpireat_spec.rb
398
399
  - spec/commands/ping_spec.rb
399
400
  - spec/commands/pipelined_spec.rb
401
+ - spec/commands/psetex_spec.rb
400
402
  - spec/commands/pttl_spec.rb
401
403
  - spec/commands/quit_spec.rb
402
404
  - spec/commands/randomkey_spec.rb