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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/mock_redis/string_methods.rb +10 -0
- data/lib/mock_redis/version.rb +1 -1
- data/spec/commands/psetex_spec.rb +44 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9f945150c69e6ff81838d4e029f1620ade56e9da6c3cb2ed0550cd61060335a
|
4
|
+
data.tar.gz: fbd58f70dbf78b770a6d3e04351771a1d94a7cac87afbff95213c92bceb16eaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9320958fc6e3360f26317dfcb47747bf8d39d626d54c0297cece31b9521fc4ad991acdccf885428d05f8b82765cfec12a37af4de33473f4106c7e3eb4e9c2b69
|
7
|
+
data.tar.gz: 05c04acff0f82500f114a868ed40aef95fc115e367ed94008075ddd90de5550dd939ca12215ffb3c88021a6aeff18cd3f9ff51dfabcc3f14244b40465d6184f0
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/lib/mock_redis/version.rb
CHANGED
@@ -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.
|
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-
|
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
|