debian-mirror-gitlab/spec/lib/gitlab/redis/repository_cache_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1,014 B
Ruby
Raw Normal View History

2023-03-17 16:20:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Redis::RepositoryCache, feature_category: :scalability do
include_examples "redis_new_instance_shared_examples", 'repository_cache', Gitlab::Redis::Cache
2023-04-23 21:23:45 +05:30
describe '#raw_config_hash' do
it 'has a legacy default URL' do
expect(subject).to receive(:fetch_config).and_return(false)
2023-03-17 16:20:25 +05:30
2023-04-23 21:23:45 +05:30
expect(subject.send(:raw_config_hash)).to eq(url: 'redis://localhost:6380')
2023-03-17 16:20:25 +05:30
end
2023-04-23 21:23:45 +05:30
end
2023-03-17 16:20:25 +05:30
2023-04-23 21:23:45 +05:30
describe '.cache_store' do
it 'has a default ttl of 8 hours' do
expect(described_class.cache_store.options[:expires_in]).to eq(8.hours)
2023-03-17 16:20:25 +05:30
end
2023-04-23 21:23:45 +05:30
context 'when encountering an error' do
subject { described_class.cache_store.read('x') }
2023-03-17 16:20:25 +05:30
2023-04-23 21:23:45 +05:30
before do
described_class.with do |redis|
allow(redis).to receive(:get).and_raise(::Redis::CommandError)
end
2023-03-17 16:20:25 +05:30
end
2023-04-23 21:23:45 +05:30
it 'logs error' do
expect(::Gitlab::ErrorTracking).to receive(:log_exception)
subject
end
2023-03-17 16:20:25 +05:30
end
end
end