Welcome to mirror list, hosted at ThFree Co, Russian Federation.

redis_interface_spec.rb « mergeability « merge_requests « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 787ac2874d35d4467a9ae38d37c0fb36ce18a697 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::MergeRequests::Mergeability::RedisInterface, :clean_gitlab_redis_cache do
  subject(:redis_interface) { described_class.new }

  let(:merge_check) { double(cache_key: '13') }
  let(:result_hash) { { test: 'test' } }
  let(:expected_key) { "#{merge_check.cache_key}:#{described_class::VERSION}" }

  describe '#save_check' do
    it 'saves the hash' do
      expect(Gitlab::Redis::Cache.with { |redis| redis.get(expected_key) }).to be_nil

      redis_interface.save_check(merge_check: merge_check, result_hash: result_hash)

      expect(Gitlab::Redis::Cache.with { |redis| redis.get(expected_key) }).to eq result_hash.to_json
    end
  end

  describe '#retrieve_check' do
    it 'returns the hash' do
      Gitlab::Redis::Cache.with { |redis| redis.set(expected_key, result_hash.to_json) }

      expect(redis_interface.retrieve_check(merge_check: merge_check)).to eq result_hash
    end
  end
end