mock_redis 0.19.0 → 0.44.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 +161 -0
- data/LICENSE.md +21 -0
- data/README.md +41 -17
- data/lib/mock_redis/connection_method.rb +13 -0
- data/lib/mock_redis/database.rb +116 -41
- data/lib/mock_redis/expire_wrapper.rb +1 -1
- data/lib/mock_redis/future.rb +1 -1
- data/lib/mock_redis/geospatial_methods.rb +13 -21
- data/lib/mock_redis/hash_methods.rb +34 -15
- data/lib/mock_redis/indifferent_hash.rb +0 -8
- data/lib/mock_redis/info_method.rb +2 -2
- data/lib/mock_redis/list_methods.rb +39 -4
- data/lib/mock_redis/memory_method.rb +11 -0
- data/lib/mock_redis/multi_db_wrapper.rb +4 -4
- data/lib/mock_redis/pipelined_wrapper.rb +32 -15
- data/lib/mock_redis/set_methods.rb +34 -6
- data/lib/mock_redis/stream/id.rb +58 -0
- data/lib/mock_redis/stream.rb +88 -0
- data/lib/mock_redis/stream_methods.rb +102 -0
- data/lib/mock_redis/string_methods.rb +81 -30
- data/lib/mock_redis/transaction_wrapper.rb +32 -21
- data/lib/mock_redis/utility_methods.rb +9 -4
- data/lib/mock_redis/version.rb +1 -1
- data/lib/mock_redis/zset.rb +5 -8
- data/lib/mock_redis/zset_methods.rb +64 -12
- data/lib/mock_redis.rb +38 -10
- metadata +40 -336
- data/.gitignore +0 -5
- data/.mailmap +0 -2
- data/.overcommit.yml +0 -21
- data/.rspec +0 -1
- data/.rubocop.yml +0 -121
- data/.rubocop_todo.yml +0 -35
- data/.simplecov +0 -4
- data/.travis.yml +0 -33
- data/Gemfile +0 -12
- data/LICENSE +0 -19
- data/Rakefile +0 -2
- data/mock_redis.gemspec +0 -30
- data/spec/client_spec.rb +0 -17
- data/spec/cloning_spec.rb +0 -95
- data/spec/commands/append_spec.rb +0 -24
- data/spec/commands/auth_spec.rb +0 -7
- data/spec/commands/bgrewriteaof_spec.rb +0 -7
- data/spec/commands/bgsave_spec.rb +0 -7
- data/spec/commands/bitcount_spec.rb +0 -25
- data/spec/commands/bitfield_spec.rb +0 -169
- data/spec/commands/blpop_spec.rb +0 -59
- data/spec/commands/brpop_spec.rb +0 -58
- data/spec/commands/brpoplpush_spec.rb +0 -52
- data/spec/commands/connected_spec.rb +0 -7
- data/spec/commands/dbsize_spec.rb +0 -18
- data/spec/commands/decr_spec.rb +0 -34
- data/spec/commands/decrby_spec.rb +0 -34
- data/spec/commands/del_spec.rb +0 -35
- data/spec/commands/disconnect_spec.rb +0 -7
- data/spec/commands/echo_spec.rb +0 -11
- data/spec/commands/eval_spec.rb +0 -7
- data/spec/commands/evalsha_spec.rb +0 -10
- data/spec/commands/exists_spec.rb +0 -14
- data/spec/commands/expire_spec.rb +0 -111
- data/spec/commands/expireat_spec.rb +0 -47
- data/spec/commands/flushall_spec.rb +0 -38
- data/spec/commands/flushdb_spec.rb +0 -38
- data/spec/commands/future_spec.rb +0 -20
- data/spec/commands/geoadd_spec.rb +0 -58
- data/spec/commands/geodist_spec.rb +0 -114
- data/spec/commands/geohash_spec.rb +0 -52
- data/spec/commands/geopos_spec.rb +0 -55
- data/spec/commands/get_spec.rb +0 -30
- data/spec/commands/getbit_spec.rb +0 -34
- data/spec/commands/getrange_spec.rb +0 -22
- data/spec/commands/getset_spec.rb +0 -23
- data/spec/commands/hash_operator_spec.rb +0 -21
- data/spec/commands/hdel_spec.rb +0 -54
- data/spec/commands/hexists_spec.rb +0 -27
- data/spec/commands/hget_spec.rb +0 -28
- data/spec/commands/hgetall_spec.rb +0 -32
- data/spec/commands/hincrby_spec.rb +0 -58
- data/spec/commands/hincrbyfloat_spec.rb +0 -58
- data/spec/commands/hkeys_spec.rb +0 -19
- data/spec/commands/hlen_spec.rb +0 -19
- data/spec/commands/hmget_spec.rb +0 -40
- data/spec/commands/hmset_spec.rb +0 -43
- data/spec/commands/hscan_each_spec.rb +0 -48
- data/spec/commands/hscan_spec.rb +0 -27
- data/spec/commands/hset_spec.rb +0 -38
- data/spec/commands/hsetnx_spec.rb +0 -44
- data/spec/commands/hvals_spec.rb +0 -19
- data/spec/commands/incr_spec.rb +0 -34
- data/spec/commands/incrby_spec.rb +0 -44
- data/spec/commands/incrbyfloat_spec.rb +0 -44
- data/spec/commands/info_spec.rb +0 -62
- data/spec/commands/keys_spec.rb +0 -122
- data/spec/commands/lastsave_spec.rb +0 -8
- data/spec/commands/lindex_spec.rb +0 -49
- data/spec/commands/linsert_spec.rb +0 -68
- data/spec/commands/llen_spec.rb +0 -16
- data/spec/commands/lpop_spec.rb +0 -34
- data/spec/commands/lpush_spec.rb +0 -43
- data/spec/commands/lpushx_spec.rb +0 -46
- data/spec/commands/lrange_spec.rb +0 -51
- data/spec/commands/lrem_spec.rb +0 -80
- data/spec/commands/lset_spec.rb +0 -43
- data/spec/commands/ltrim_spec.rb +0 -45
- data/spec/commands/mapped_hmget_spec.rb +0 -29
- data/spec/commands/mapped_hmset_spec.rb +0 -47
- data/spec/commands/mapped_mget_spec.rb +0 -22
- data/spec/commands/mapped_mset_spec.rb +0 -19
- data/spec/commands/mapped_msetnx_spec.rb +0 -26
- data/spec/commands/mget_spec.rb +0 -34
- data/spec/commands/move_spec.rb +0 -147
- data/spec/commands/mset_spec.rb +0 -29
- data/spec/commands/msetnx_spec.rb +0 -40
- data/spec/commands/persist_spec.rb +0 -48
- data/spec/commands/pexpire_spec.rb +0 -86
- data/spec/commands/pexpireat_spec.rb +0 -48
- data/spec/commands/ping_spec.rb +0 -7
- data/spec/commands/pipelined_spec.rb +0 -42
- data/spec/commands/pttl_spec.rb +0 -41
- data/spec/commands/quit_spec.rb +0 -7
- data/spec/commands/randomkey_spec.rb +0 -20
- data/spec/commands/rename_spec.rb +0 -42
- data/spec/commands/renamenx_spec.rb +0 -41
- data/spec/commands/rpop_spec.rb +0 -34
- data/spec/commands/rpoplpush_spec.rb +0 -50
- data/spec/commands/rpush_spec.rb +0 -43
- data/spec/commands/rpushx_spec.rb +0 -46
- data/spec/commands/sadd_spec.rb +0 -45
- data/spec/commands/save_spec.rb +0 -7
- data/spec/commands/scan_each_spec.rb +0 -39
- data/spec/commands/scan_spec.rb +0 -55
- data/spec/commands/scard_spec.rb +0 -18
- data/spec/commands/script_spec.rb +0 -9
- data/spec/commands/sdiff_spec.rb +0 -47
- data/spec/commands/sdiffstore_spec.rb +0 -58
- data/spec/commands/select_spec.rb +0 -61
- data/spec/commands/set_spec.rb +0 -63
- data/spec/commands/setbit_spec.rb +0 -54
- data/spec/commands/setex_spec.rb +0 -22
- data/spec/commands/setnx_spec.rb +0 -25
- data/spec/commands/setrange_spec.rb +0 -30
- data/spec/commands/sinter_spec.rb +0 -39
- data/spec/commands/sinterstore_spec.rb +0 -53
- data/spec/commands/sismember_spec.rb +0 -29
- data/spec/commands/smembers_spec.rb +0 -28
- data/spec/commands/smove_spec.rb +0 -41
- data/spec/commands/sort_list_spec.rb +0 -21
- data/spec/commands/sort_set_spec.rb +0 -21
- data/spec/commands/sort_zset_spec.rb +0 -21
- data/spec/commands/spop_spec.rb +0 -25
- data/spec/commands/srandmember_spec.rb +0 -49
- data/spec/commands/srem_spec.rb +0 -40
- data/spec/commands/sscan_each_spec.rb +0 -48
- data/spec/commands/sscan_spec.rb +0 -39
- data/spec/commands/strlen_spec.rb +0 -18
- data/spec/commands/sunion_spec.rb +0 -42
- data/spec/commands/sunionstore_spec.rb +0 -59
- data/spec/commands/ttl_spec.rb +0 -40
- data/spec/commands/type_spec.rb +0 -36
- data/spec/commands/unwatch_spec.rb +0 -7
- data/spec/commands/watch_spec.rb +0 -16
- data/spec/commands/zadd_spec.rb +0 -123
- data/spec/commands/zcard_spec.rb +0 -19
- data/spec/commands/zcount_spec.rb +0 -39
- data/spec/commands/zincrby_spec.rb +0 -31
- data/spec/commands/zinterstore_spec.rb +0 -96
- data/spec/commands/zrange_spec.rb +0 -80
- data/spec/commands/zrangebyscore_spec.rb +0 -83
- data/spec/commands/zrank_spec.rb +0 -29
- data/spec/commands/zrem_spec.rb +0 -43
- data/spec/commands/zremrangebyrank_spec.rb +0 -27
- data/spec/commands/zremrangebyscore_spec.rb +0 -35
- data/spec/commands/zrevrange_spec.rb +0 -56
- data/spec/commands/zrevrangebyscore_spec.rb +0 -58
- data/spec/commands/zrevrank_spec.rb +0 -29
- data/spec/commands/zscan_each_spec.rb +0 -48
- data/spec/commands/zscan_spec.rb +0 -26
- data/spec/commands/zscore_spec.rb +0 -22
- data/spec/commands/zunionstore_spec.rb +0 -104
- data/spec/mock_redis_spec.rb +0 -86
- data/spec/spec_helper.rb +0 -63
- data/spec/support/redis_multiplexer.rb +0 -106
- data/spec/support/shared_examples/only_operates_on_hashes.rb +0 -13
- data/spec/support/shared_examples/only_operates_on_lists.rb +0 -13
- data/spec/support/shared_examples/only_operates_on_sets.rb +0 -13
- data/spec/support/shared_examples/only_operates_on_strings.rb +0 -13
- data/spec/support/shared_examples/only_operates_on_zsets.rb +0 -57
- data/spec/support/shared_examples/sorts_enumerables.rb +0 -56
- data/spec/transactions_spec.rb +0 -159
data/.rubocop.yml
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
inherit_from: .rubocop_todo.yml
|
2
|
-
|
3
|
-
AllCops:
|
4
|
-
TargetRubyVersion: 2.2
|
5
|
-
|
6
|
-
Layout/AlignParameters:
|
7
|
-
Enabled: false
|
8
|
-
|
9
|
-
Layout/DotPosition:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
Lint/AssignmentInCondition:
|
13
|
-
Enabled: false
|
14
|
-
|
15
|
-
# We use this a lot in specs where it's perfectly valid
|
16
|
-
Lint/Void:
|
17
|
-
Exclude:
|
18
|
-
- spec/**/*
|
19
|
-
|
20
|
-
Metrics/AbcSize:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
Metrics/BlockLength:
|
24
|
-
Enabled: false
|
25
|
-
|
26
|
-
Metrics/CyclomaticComplexity:
|
27
|
-
Enabled: false
|
28
|
-
|
29
|
-
Metrics/ClassLength:
|
30
|
-
Enabled: false
|
31
|
-
|
32
|
-
Metrics/LineLength:
|
33
|
-
Max: 100
|
34
|
-
|
35
|
-
Metrics/MethodLength:
|
36
|
-
Enabled: false
|
37
|
-
|
38
|
-
Metrics/ModuleLength:
|
39
|
-
Enabled: false
|
40
|
-
|
41
|
-
Metrics/PerceivedComplexity:
|
42
|
-
Enabled: false
|
43
|
-
|
44
|
-
# This hides the has-a versus is-a relationship indicated by the method name
|
45
|
-
Naming/PredicateName:
|
46
|
-
Enabled: false
|
47
|
-
|
48
|
-
Style/Documentation:
|
49
|
-
Enabled: false
|
50
|
-
|
51
|
-
Style/DoubleNegation:
|
52
|
-
Enabled: false
|
53
|
-
|
54
|
-
# We have too much code that relies on modifying strings
|
55
|
-
Style/FrozenStringLiteralComment:
|
56
|
-
Enabled: false
|
57
|
-
|
58
|
-
Style/GuardClause:
|
59
|
-
Enabled: false
|
60
|
-
|
61
|
-
Style/HashSyntax:
|
62
|
-
Enabled: false
|
63
|
-
|
64
|
-
Style/IfUnlessModifier:
|
65
|
-
Enabled: false
|
66
|
-
|
67
|
-
Style/Lambda:
|
68
|
-
Enabled: false
|
69
|
-
|
70
|
-
# TODO: Address these at some point
|
71
|
-
Style/MethodMissingSuper:
|
72
|
-
Enabled: false
|
73
|
-
|
74
|
-
Style/MissingRespondToMissing:
|
75
|
-
Enabled: false
|
76
|
-
|
77
|
-
Style/MultilineBlockChain:
|
78
|
-
Enabled: false
|
79
|
-
|
80
|
-
Style/NumericPredicate:
|
81
|
-
Enabled: false
|
82
|
-
|
83
|
-
# Prefer curly braces except for %i/%w/%W, since those return arrays.
|
84
|
-
Style/PercentLiteralDelimiters:
|
85
|
-
PreferredDelimiters:
|
86
|
-
'%': '{}'
|
87
|
-
'%i': '[]'
|
88
|
-
'%q': '{}'
|
89
|
-
'%Q': '{}'
|
90
|
-
'%r': '{}'
|
91
|
-
'%s': '()'
|
92
|
-
'%w': '[]'
|
93
|
-
'%W': '[]'
|
94
|
-
'%x': '{}'
|
95
|
-
|
96
|
-
Style/PerlBackrefs:
|
97
|
-
Enabled: false
|
98
|
-
|
99
|
-
Style/RescueModifier:
|
100
|
-
Enabled: false
|
101
|
-
|
102
|
-
Style/SignalException:
|
103
|
-
Enabled: false
|
104
|
-
|
105
|
-
Style/SingleLineBlockParams:
|
106
|
-
Enabled: false
|
107
|
-
|
108
|
-
Style/SymbolArray:
|
109
|
-
Enabled: false
|
110
|
-
|
111
|
-
Style/TrailingCommaInArguments:
|
112
|
-
Enabled: false
|
113
|
-
|
114
|
-
Style/TrailingCommaInArrayLiteral:
|
115
|
-
Enabled: false
|
116
|
-
|
117
|
-
Style/TrailingCommaInHashLiteral:
|
118
|
-
Enabled: false
|
119
|
-
|
120
|
-
Style/WhenThen:
|
121
|
-
Enabled: false
|
data/.rubocop_todo.yml
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-08-03 11:15:53 -0700 using RuboCop version 0.58.2.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 17
|
10
|
-
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
11
|
-
# AllowedNames: io, id, to, by, on, in, at, ip
|
12
|
-
Naming/UncommunicativeMethodParamName:
|
13
|
-
Exclude:
|
14
|
-
- 'lib/mock_redis/database.rb'
|
15
|
-
- 'lib/mock_redis/expire_wrapper.rb'
|
16
|
-
- 'lib/mock_redis/geospatial_methods.rb'
|
17
|
-
- 'lib/mock_redis/multi_db_wrapper.rb'
|
18
|
-
- 'lib/mock_redis/pipelined_wrapper.rb'
|
19
|
-
- 'lib/mock_redis/string_methods.rb'
|
20
|
-
- 'lib/mock_redis/transaction_wrapper.rb'
|
21
|
-
- 'lib/mock_redis/utility_methods.rb'
|
22
|
-
- 'lib/mock_redis/zset_methods.rb'
|
23
|
-
- 'spec/support/redis_multiplexer.rb'
|
24
|
-
|
25
|
-
# Offense count: 2
|
26
|
-
# Configuration parameters: EnforcedStyle.
|
27
|
-
# SupportedStyles: inline, group
|
28
|
-
Style/AccessModifierDeclarations:
|
29
|
-
Exclude:
|
30
|
-
- 'lib/mock_redis/zset_methods.rb'
|
31
|
-
|
32
|
-
# Offense count: 1
|
33
|
-
Style/DateTime:
|
34
|
-
Exclude:
|
35
|
-
- 'spec/commands/zremrangebyscore_spec.rb'
|
data/.simplecov
DELETED
data/.travis.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
sudo: false
|
4
|
-
|
5
|
-
cache: bundler
|
6
|
-
|
7
|
-
addons:
|
8
|
-
apt:
|
9
|
-
packages:
|
10
|
-
- redis-server
|
11
|
-
|
12
|
-
services:
|
13
|
-
- redis-server
|
14
|
-
|
15
|
-
rvm:
|
16
|
-
- 2.2
|
17
|
-
- 2.3.7
|
18
|
-
- 2.4.4
|
19
|
-
- 2.5.1
|
20
|
-
|
21
|
-
before_script:
|
22
|
-
- git config --local user.email "travis@travis.ci"
|
23
|
-
- git config --local user.name "Travis CI"
|
24
|
-
|
25
|
-
script:
|
26
|
-
- redis-cli --version
|
27
|
-
- bundle exec rspec
|
28
|
-
- bundle exec overcommit --sign
|
29
|
-
- bundle exec overcommit --run
|
30
|
-
|
31
|
-
matrix:
|
32
|
-
allow_failures:
|
33
|
-
- rvm: 2.1.0
|
data/Gemfile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
source 'http://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in mock_redis.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
# Run all pre-commit hooks via Overcommit during CI runs
|
7
|
-
gem 'overcommit', '0.45.0'
|
8
|
-
|
9
|
-
# Pin tool versions (which are executed by Overcommit) for Travis builds
|
10
|
-
gem 'rubocop', '0.58.2'
|
11
|
-
|
12
|
-
gem 'coveralls', require: false
|
data/LICENSE
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Philotic, Inc.
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/mock_redis.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
$LOAD_PATH << File.expand_path('lib', __dir__)
|
2
|
-
require 'mock_redis/version'
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = 'mock_redis'
|
6
|
-
s.version = MockRedis::VERSION
|
7
|
-
s.license = 'MIT'
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ['Brigade Engineering', 'Samuel Merritt']
|
10
|
-
s.email = ['eng@brigade.com']
|
11
|
-
s.homepage = 'https://github.com/brigade/mock_redis'
|
12
|
-
s.summary = 'Redis mock that just lives in memory; useful for testing.'
|
13
|
-
|
14
|
-
s.description = <<-MSG.strip.gsub(/\s+/, ' ')
|
15
|
-
Instantiate one with `redis = MockRedis.new` and treat it like you would a
|
16
|
-
normal Redis object. It supports all the usual Redis operations.
|
17
|
-
MSG
|
18
|
-
|
19
|
-
s.files = `git ls-files`.split("\n")
|
20
|
-
s.test_files = `git ls-files -- spec/*`.split("\n")
|
21
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
22
|
-
s.require_paths = ['lib']
|
23
|
-
|
24
|
-
s.required_ruby_version = '>= 2.2'
|
25
|
-
|
26
|
-
s.add_development_dependency 'rake', '>= 10', '< 12'
|
27
|
-
s.add_development_dependency 'redis', '~> 3.3.0'
|
28
|
-
s.add_development_dependency 'rspec', '~> 3.0'
|
29
|
-
s.add_development_dependency 'rspec-its', '~> 1.0'
|
30
|
-
end
|
data/spec/client_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'client' do
|
4
|
-
context '#reconnect' do
|
5
|
-
it 'reconnects' do
|
6
|
-
redis = MockRedis.new
|
7
|
-
redis.reconnect.should == redis
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
context '#connect' do
|
12
|
-
it 'connects' do
|
13
|
-
redis = MockRedis.new
|
14
|
-
redis.connect.should == redis
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/spec/cloning_spec.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'MockRedis#clone' do
|
4
|
-
before do
|
5
|
-
@mock = MockRedis.new
|
6
|
-
end
|
7
|
-
|
8
|
-
context 'the stored data' do
|
9
|
-
before do
|
10
|
-
@mock.set('foo', 'bar')
|
11
|
-
@mock.hset('foohash', 'bar', 'baz')
|
12
|
-
@mock.lpush('foolist', 'bar')
|
13
|
-
@mock.sadd('fooset', 'bar')
|
14
|
-
@mock.zadd('foozset', 1, 'bar')
|
15
|
-
|
16
|
-
@clone = @mock.clone
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'copies the stored data to the clone' do
|
20
|
-
@clone.get('foo').should == 'bar'
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'performs a deep copy (string values)' do
|
24
|
-
@mock.del('foo')
|
25
|
-
@clone.get('foo').should == 'bar'
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'performs a deep copy (list values)' do
|
29
|
-
@mock.lpop('foolist')
|
30
|
-
@clone.lrange('foolist', 0, 1).should == ['bar']
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'performs a deep copy (hash values)' do
|
34
|
-
@mock.hset('foohash', 'bar', 'quux')
|
35
|
-
@clone.hgetall('foohash').should == { 'bar' => 'baz' }
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'performs a deep copy (set values)' do
|
39
|
-
@mock.srem('fooset', 'bar')
|
40
|
-
@clone.smembers('fooset').should == ['bar']
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'performs a deep copy (zset values)' do
|
44
|
-
@mock.zadd('foozset', 2, 'bar')
|
45
|
-
@clone.zscore('foozset', 'bar').should == 1.0
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'expiration times' do
|
50
|
-
before do
|
51
|
-
@mock.set('foo', 1)
|
52
|
-
@mock.expire('foo', 60_026)
|
53
|
-
|
54
|
-
@clone = @mock.clone
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'copies the expiration times' do
|
58
|
-
@clone.ttl('foo').should > 0
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'deep-copies the expiration times' do
|
62
|
-
@mock.persist('foo')
|
63
|
-
@clone.ttl('foo').should > 0
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'deep-copies the expiration times' do
|
67
|
-
@clone.persist('foo')
|
68
|
-
@mock.ttl('foo').should > 0
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'transactional info' do
|
73
|
-
before do
|
74
|
-
@mock.multi
|
75
|
-
@mock.incr('foo')
|
76
|
-
@mock.incrby('foo', 2)
|
77
|
-
@mock.incrby('foo', 4)
|
78
|
-
|
79
|
-
@clone = @mock.clone
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'makes sure the clone is in a transaction' do
|
83
|
-
lambda do
|
84
|
-
@clone.exec
|
85
|
-
end.should_not raise_error
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'deep-copies the queued commands' do
|
89
|
-
@clone.incrby('foo', 8)
|
90
|
-
@clone.exec.should == [1, 3, 7, 15]
|
91
|
-
|
92
|
-
@mock.exec.should == [1, 3, 7]
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe '#append(key, value)' do
|
4
|
-
before { @key = 'mock-redis-test:append' }
|
5
|
-
|
6
|
-
it 'returns the new length of the string' do
|
7
|
-
@redises.set(@key, 'porkchop')
|
8
|
-
@redises.append(@key, 'sandwiches').should == 18
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'appends value to the previously-stored value' do
|
12
|
-
@redises.set(@key, 'porkchop')
|
13
|
-
@redises.append(@key, 'sandwiches')
|
14
|
-
|
15
|
-
@redises.get(@key).should == 'porkchopsandwiches'
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'treats a missing key as an empty string' do
|
19
|
-
@redises.append(@key, 'foo')
|
20
|
-
@redises.get(@key).should == 'foo'
|
21
|
-
end
|
22
|
-
|
23
|
-
it_should_behave_like 'a string-only command'
|
24
|
-
end
|
data/spec/commands/auth_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe '#bitcount(key [, start, end ])' do
|
4
|
-
before do
|
5
|
-
@key = 'mock-redis-test:bitcount'
|
6
|
-
@redises.set(@key, 'foobar')
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'gets the number of set bits from the key' do
|
10
|
-
@redises.bitcount(@key).should == 26
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'gets the number of set bits from the key in an interval' do
|
14
|
-
@redises.bitcount(@key, 0, 1000).should == 26
|
15
|
-
@redises.bitcount(@key, 0, 0).should == 4
|
16
|
-
@redises.bitcount(@key, 1, 1).should == 6
|
17
|
-
@redises.bitcount(@key, 1, -2).should == 18
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'treats nonexistent keys as empty strings' do
|
21
|
-
@redises.bitcount('mock-redis-test:not-found').should == 0
|
22
|
-
end
|
23
|
-
|
24
|
-
it_should_behave_like 'a string-only command'
|
25
|
-
end
|
@@ -1,169 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe '#bitfield(*args)' do
|
4
|
-
before :each do
|
5
|
-
@key = 'mock-redis-test:bitfield'
|
6
|
-
@redises.set(@key, '')
|
7
|
-
|
8
|
-
@redises.bitfield(@key, :set, 'i8', 0, 78)
|
9
|
-
@redises.bitfield(@key, :set, 'i8', 8, 104)
|
10
|
-
@redises.bitfield(@key, :set, 'i8', 16, -59)
|
11
|
-
@redises.bitfield(@key, :set, 'u8', 24, 78)
|
12
|
-
@redises.bitfield(@key, :set, 'u8', 32, 84)
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'with a :get command' do
|
16
|
-
it 'gets a signed 8 bit value' do
|
17
|
-
@redises.bitfield(@key, :get, 'i8', 0).should == [78]
|
18
|
-
@redises.bitfield(@key, :get, 'i8', 8).should == [104]
|
19
|
-
@redises.bitfield(@key, :get, 'i8', 16).should == [-59]
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'gets multiple values with multiple command args' do
|
23
|
-
@redises.bitfield(@key, :get, 'i8', 0,
|
24
|
-
:get, 'i8', 8,
|
25
|
-
:get, 'i8', 16).should == [78, 104, -59]
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'gets multiple values using positional offsets' do
|
29
|
-
@redises.bitfield(@key, :get, 'i8', '#0',
|
30
|
-
:get, 'i8', '#1',
|
31
|
-
:get, 'i8', '#2').should == [78, 104, -59]
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'shows an error with an invalid type' do
|
35
|
-
expect do
|
36
|
-
@redises.bitfield(@key, :get, 'u64', 0)
|
37
|
-
end.to raise_error(Redis::CommandError)
|
38
|
-
expect do
|
39
|
-
@redises.bitfield(@key, :get, 'i128', 0)
|
40
|
-
end.to raise_error(Redis::CommandError)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'does not throw an error with i64 type' do
|
44
|
-
expect do
|
45
|
-
@redises.bitfield(@key, :get, 'i64', 0)
|
46
|
-
end.to_not raise_error
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'with a :set command' do
|
51
|
-
it 'sets the bit values for an 8 bit signed integer' do
|
52
|
-
@redises.bitfield(@key, :set, 'i8', 0, 63).should == [78]
|
53
|
-
@redises.bitfield(@key, :set, 'i8', 8, -1).should == [104]
|
54
|
-
@redises.bitfield(@key, :set, 'i8', 16, 123).should == [-59]
|
55
|
-
|
56
|
-
@redises.bitfield(@key, :get, 'i8', 0,
|
57
|
-
:get, 'i8', 8,
|
58
|
-
:get, 'i8', 16).should == [63, -1, 123]
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'sets multiple values with multiple command args' do
|
62
|
-
@redises.bitfield(@key, :set, 'i8', 0, 63,
|
63
|
-
:set, 'i8', 8, -1,
|
64
|
-
:set, 'i8', 16, 123).should == [78, 104, -59]
|
65
|
-
|
66
|
-
@redises.bitfield(@key, :get, 'i8', 0,
|
67
|
-
:get, 'i8', 8,
|
68
|
-
:get, 'i8', 16).should == [63, -1, 123]
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'with an :incrby command' do
|
73
|
-
it 'returns the incremented by value for an 8 bit signed integer' do
|
74
|
-
@redises.bitfield(@key, :incrby, 'i8', 0, 1).should == [79]
|
75
|
-
@redises.bitfield(@key, :incrby, 'i8', 8, -1).should == [103]
|
76
|
-
@redises.bitfield(@key, :incrby, 'i8', 16, 5).should == [-54]
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'with an overflow of wrap (default)' do
|
80
|
-
context 'for a signed integer' do
|
81
|
-
it 'wraps the overflow to the minimum and increments from there' do
|
82
|
-
@redises.bitfield(@key, :get, 'i8', 24).should == [78]
|
83
|
-
@redises.bitfield(@key, :overflow, :wrap,
|
84
|
-
:incrby, 'i8', 0, 200).should == [22]
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'wraps the underflow to the maximum value and decrements from there' do
|
88
|
-
@redises.bitfield(@key, :overflow, :wrap,
|
89
|
-
:incrby, 'i8', 16, -200).should == [-3]
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'for an unsigned integer' do
|
94
|
-
it 'wraps the overflow back to zero and increments from there' do
|
95
|
-
@redises.bitfield(@key, :get, 'u8', 24).should == [78]
|
96
|
-
@redises.bitfield(@key, :overflow, :wrap,
|
97
|
-
:incrby, 'u8', 24, 233).should == [55]
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'wraps the underflow to the maximum value and decrements from there' do
|
101
|
-
@redises.bitfield(@key, :get, 'u8', 32).should == [84]
|
102
|
-
@redises.bitfield(@key, :overflow, :wrap,
|
103
|
-
:incrby, 'u8', 32, -233).should == [107]
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'with an overflow of sat' do
|
109
|
-
it 'sets the overflowed value to the maximum' do
|
110
|
-
@redises.bitfield(@key, :overflow, :sat,
|
111
|
-
:incrby, 'i8', 0, 256).should == [127]
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'sets the underflowed value to the minimum' do
|
115
|
-
@redises.bitfield(@key, :overflow, :sat,
|
116
|
-
:incrby, 'i8', 16, -256).should == [-128]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'with an overflow of fail' do
|
121
|
-
it 'raises a redis error on an out of range value' do
|
122
|
-
@redises.bitfield(@key, :overflow, :fail,
|
123
|
-
:incrby, 'i8', 0, 256).should == [nil]
|
124
|
-
|
125
|
-
@redises.bitfield(@key, :overflow, :fail,
|
126
|
-
:incrby, 'i8', 16, -256).should == [nil]
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'retains the original value after a failed increment' do
|
130
|
-
@redises.bitfield(@key, :get, 'i8', 0).should == [78]
|
131
|
-
@redises.bitfield(@key, :overflow, :fail,
|
132
|
-
:incrby, 'i8', 0, 256).should == [nil]
|
133
|
-
@redises.bitfield(@key, :get, 'i8', 0).should == [78]
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context 'with multiple overflow commands in one transaction' do
|
138
|
-
it 'handles the overflow values correctly' do
|
139
|
-
@redises.bitfield(@key, :overflow, :sat,
|
140
|
-
:incrby, 'i8', 0, 256,
|
141
|
-
:incrby, 'i8', 8, -256,
|
142
|
-
:overflow, :wrap,
|
143
|
-
:incrby, 'i8', 0, 200,
|
144
|
-
:incrby, 'i8', 16, -200,
|
145
|
-
:overflow, :fail,
|
146
|
-
:incrby, 'i8', 0, 256,
|
147
|
-
:incrby, 'i8', 16, -256).should == [127, -128, 71, -3, nil, nil]
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'with an unsupported overflow value' do
|
152
|
-
it 'raises an error' do
|
153
|
-
expect do
|
154
|
-
@redises.bitfield(@key, :overflow, :foo,
|
155
|
-
:incrby, 'i8', 0, 256)
|
156
|
-
end.to raise_error(Redis::CommandError)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
context 'with a mixed set of commands' do
|
162
|
-
it 'returns the correct outputs' do
|
163
|
-
@redises.bitfield(@key, :set, 'i8', 0, 38,
|
164
|
-
:set, 'i8', 8, -99,
|
165
|
-
:incrby, 'i8', 16, 1,
|
166
|
-
:get, 'i8', 0).should == [78, 104, -58, 38]
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
data/spec/commands/blpop_spec.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe '#blpop(key [, key, ...,], timeout)' do
|
4
|
-
before do
|
5
|
-
@list1 = 'mock-redis-test:blpop1'
|
6
|
-
@list2 = 'mock-redis-test:blpop2'
|
7
|
-
|
8
|
-
@redises.rpush(@list1, 'one')
|
9
|
-
@redises.rpush(@list1, 'two')
|
10
|
-
@redises.rpush(@list2, 'ten')
|
11
|
-
@redises.rpush(@list2, 'eleven')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'returns [first-nonempty-list, popped-value]' do
|
15
|
-
@redises.blpop(@list1, @list2).should == [@list1, 'one']
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'pops that value off the list' do
|
19
|
-
@redises.blpop(@list1, @list2)
|
20
|
-
@redises.blpop(@list1, @list2)
|
21
|
-
|
22
|
-
@redises.blpop(@list1, @list2).should == [@list2, 'ten']
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'ignores empty keys' do
|
26
|
-
@redises.blpop('mock-redis-test:not-here', @list1).should ==
|
27
|
-
[@list1, 'one']
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'raises an error on subsecond timeouts' do
|
31
|
-
lambda do
|
32
|
-
@redises.blpop(@list1, @list2, :timeout => 0.5)
|
33
|
-
end.should raise_error(Redis::CommandError)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'raises an error on negative timeout' do
|
37
|
-
lambda do
|
38
|
-
@redises.blpop(@list1, @list2, :timeout => -1)
|
39
|
-
end.should raise_error(Redis::CommandError)
|
40
|
-
end
|
41
|
-
|
42
|
-
it_should_behave_like 'a list-only command'
|
43
|
-
|
44
|
-
context '[mock only]' do
|
45
|
-
it 'ignores positive timeouts and returns nil' do
|
46
|
-
@redises.mock.blpop('mock-redis-test:not-here', :timeout => 1).should be_nil
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'ignores positive legacy timeouts and returns nil' do
|
50
|
-
@redises.mock.blpop('mock-redis-test:not-here', 1).should be_nil
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'raises WouldBlock on zero timeout (no blocking in the mock)' do
|
54
|
-
lambda do
|
55
|
-
@redises.mock.blpop('mock-redis-test:not-here', :timeout => 0)
|
56
|
-
end.should raise_error(MockRedis::WouldBlock)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|