diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 00:09:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-17 00:09:21 +0300 |
commit | 87af6f2e0590af0ed1bb3e5de1bb5d21855a94d2 (patch) | |
tree | 2abe2661b10cf6281bc03855b3053a072c64fbbf /spec/lib/gitlab/repository_set_cache_spec.rb | |
parent | c43ba2677f41ad0b5fc6f3af6baf4266c70dfcb3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/repository_set_cache_spec.rb')
-rw-r--r-- | spec/lib/gitlab/repository_set_cache_spec.rb | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/spec/lib/gitlab/repository_set_cache_spec.rb b/spec/lib/gitlab/repository_set_cache_spec.rb index bcf27b338f6..c5d95e53120 100644 --- a/spec/lib/gitlab/repository_set_cache_spec.rb +++ b/spec/lib/gitlab/repository_set_cache_spec.rb @@ -51,12 +51,52 @@ describe Gitlab::RepositorySetCache, :clean_gitlab_redis_cache do end describe '#expire' do - it 'expires the given key from the cache' do + subject { cache.expire(*keys) } + + before do cache.write(:foo, ['value']) + cache.write(:bar, ['value2']) + end + it 'actually wrote the values' do expect(cache.read(:foo)).to contain_exactly('value') - expect(cache.expire(:foo)).to eq(1) - expect(cache.read(:foo)).to be_empty + expect(cache.read(:bar)).to contain_exactly('value2') + end + + context 'single key' do + let(:keys) { %w(foo) } + + it { is_expected.to eq(1) } + + it 'deletes the given key from the cache' do + subject + + expect(cache.read(:foo)).to be_empty + end + end + + context 'multiple keys' do + let(:keys) { %w(foo bar) } + + it { is_expected.to eq(2) } + + it 'deletes the given keys from the cache' do + subject + + expect(cache.read(:foo)).to be_empty + expect(cache.read(:bar)).to be_empty + end + end + + context "unlink isn't supported" do + before do + allow_any_instance_of(Redis).to receive(:unlink) { raise ::Redis::CommandError } + end + + it 'still deletes the given key' do + expect(cache.expire(:foo)).to eq(1) + expect(cache.read(:foo)).to be_empty + end end end |