blob: d2016ef0248e509af4dbfdc8d1d19e368ed88c81 (
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::GithubGistsImport::Status, :clean_gitlab_redis_cache, feature_category: :importers do
subject(:import_status) { described_class.new(user.id) }
let_it_be(:user) { create(:user) }
let(:key) { "gitlab:github-gists-import:#{user.id}" }
describe '#start!' do
it 'expires the key' do
import_status.start!
Gitlab::Redis::SharedState.with do |redis|
expect(redis.get(key)).to eq('started')
end
end
end
describe '#fail!' do
it 'sets failed status' do
import_status.fail!
Gitlab::Redis::SharedState.with do |redis|
expect(redis.get(key)).to eq('failed')
end
end
end
describe '#finish!' do
it 'sets finished status' do
import_status.finish!
Gitlab::Redis::SharedState.with do |redis|
expect(redis.get(key)).to eq('finished')
end
end
end
describe '#started?' do
before do
Gitlab::Redis::SharedState.with { |redis| redis.set(key, 'started') }
end
it 'checks if status is started' do
expect(import_status.started?).to eq(true)
end
end
end
|