2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
2022-10-11 01:57:18 +05:30
|
|
|
require 'gitlab/redis'
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
RSpec.configure do |config|
|
|
|
|
config.after(:each, :redis) do
|
|
|
|
Sidekiq.redis do |connection|
|
|
|
|
connection.redis.flushdb
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
Gitlab::Redis::ALL_CLASSES.each do |instance_class|
|
|
|
|
underscored_name = instance_class.store_name.underscore
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
config.around(:each, :"clean_gitlab_redis_#{underscored_name}") do |example|
|
|
|
|
public_send("redis_#{underscored_name}_cleanup!")
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
example.run
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
public_send("redis_#{underscored_name}_cleanup!")
|
|
|
|
end
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
|
|
|
config.before(:suite) do
|
|
|
|
Gitlab::Redis::ALL_CLASSES.each do |instance_class|
|
|
|
|
instance_class.with(&:flushdb)
|
|
|
|
end
|
|
|
|
end
|
2023-04-23 21:23:45 +05:30
|
|
|
|
|
|
|
config.before(:each, :use_null_store_as_repository_cache) do |example|
|
|
|
|
null_store = ActiveSupport::Cache::NullStore.new
|
|
|
|
|
|
|
|
allow(Gitlab::Redis::RepositoryCache).to receive(:cache_store).and_return(null_store)
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|