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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-14 03:09:30 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-14 03:09:30 +0300
commit8957ace3159e5369a700a77614493ed6a8a98f93 (patch)
tree98ff5be0caa30cfebb4e0cd0ae2ceaf21ce92eb4 /spec/lib/gitlab/github_import
parent232e0a31f1e5d5b3a788dfc3dba8f8d41df36bf9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/github_import')
-rw-r--r--spec/lib/gitlab/github_import/caching_spec.rb119
-rw-r--r--spec/lib/gitlab/github_import/issuable_finder_spec.rb2
-rw-r--r--spec/lib/gitlab/github_import/label_finder_spec.rb4
-rw-r--r--spec/lib/gitlab/github_import/milestone_finder_spec.rb4
-rw-r--r--spec/lib/gitlab/github_import/page_counter_spec.rb2
-rw-r--r--spec/lib/gitlab/github_import/parallel_scheduling_spec.rb4
-rw-r--r--spec/lib/gitlab/github_import/user_finder_spec.rb22
7 files changed, 19 insertions, 138 deletions
diff --git a/spec/lib/gitlab/github_import/caching_spec.rb b/spec/lib/gitlab/github_import/caching_spec.rb
deleted file mode 100644
index 18c3e382532..00000000000
--- a/spec/lib/gitlab/github_import/caching_spec.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe Gitlab::GithubImport::Caching, :clean_gitlab_redis_cache do
- describe '.read' do
- it 'reads a value from the cache' do
- described_class.write('foo', 'bar')
-
- expect(described_class.read('foo')).to eq('bar')
- end
-
- it 'returns nil if the cache key does not exist' do
- expect(described_class.read('foo')).to be_nil
- end
-
- it 'refreshes the cache key if a value is present' do
- described_class.write('foo', 'bar')
-
- redis = double(:redis)
-
- expect(redis).to receive(:get).with(/foo/).and_return('bar')
- expect(redis).to receive(:expire).with(/foo/, described_class::TIMEOUT)
- expect(Gitlab::Redis::Cache).to receive(:with).twice.and_yield(redis)
-
- described_class.read('foo')
- end
-
- it 'does not refresh the cache key if a value is empty' do
- described_class.write('foo', nil)
-
- redis = double(:redis)
-
- expect(redis).to receive(:get).with(/foo/).and_return('')
- expect(redis).not_to receive(:expire)
- expect(Gitlab::Redis::Cache).to receive(:with).and_yield(redis)
-
- described_class.read('foo')
- end
- end
-
- describe '.read_integer' do
- it 'returns an Integer' do
- described_class.write('foo', '10')
-
- expect(described_class.read_integer('foo')).to eq(10)
- end
-
- it 'returns nil if no value was found' do
- expect(described_class.read_integer('foo')).to be_nil
- end
- end
-
- describe '.write' do
- it 'writes a value to the cache and returns the written value' do
- expect(described_class.write('foo', 10)).to eq(10)
- expect(described_class.read('foo')).to eq('10')
- end
- end
-
- describe '.set_add' do
- it 'adds a value to a set' do
- described_class.set_add('foo', 10)
- described_class.set_add('foo', 10)
-
- key = described_class.cache_key_for('foo')
- values = Gitlab::Redis::Cache.with { |r| r.smembers(key) }
-
- expect(values).to eq(['10'])
- end
- end
-
- describe '.set_includes?' do
- it 'returns false when the key does not exist' do
- expect(described_class.set_includes?('foo', 10)).to eq(false)
- end
-
- it 'returns false when the value is not present in the set' do
- described_class.set_add('foo', 10)
-
- expect(described_class.set_includes?('foo', 20)).to eq(false)
- end
-
- it 'returns true when the set includes the given value' do
- described_class.set_add('foo', 10)
-
- expect(described_class.set_includes?('foo', 10)).to eq(true)
- end
- end
-
- describe '.write_multiple' do
- it 'sets multiple keys' do
- mapping = { 'foo' => 10, 'bar' => 20 }
-
- described_class.write_multiple(mapping)
-
- mapping.each do |key, value|
- full_key = described_class.cache_key_for(key)
- found = Gitlab::Redis::Cache.with { |r| r.get(full_key) }
-
- expect(found).to eq(value.to_s)
- end
- end
- end
-
- describe '.expire' do
- it 'sets the expiration time of a key' do
- timeout = 1.hour.to_i
-
- described_class.write('foo', 'bar', timeout: 2.hours.to_i)
- described_class.expire('foo', timeout)
-
- key = described_class.cache_key_for('foo')
- found_ttl = Gitlab::Redis::Cache.with { |r| r.ttl(key) }
-
- expect(found_ttl).to be <= timeout
- end
- end
-end
diff --git a/spec/lib/gitlab/github_import/issuable_finder_spec.rb b/spec/lib/gitlab/github_import/issuable_finder_spec.rb
index b8a6feb6c73..55add863d43 100644
--- a/spec/lib/gitlab/github_import/issuable_finder_spec.rb
+++ b/spec/lib/gitlab/github_import/issuable_finder_spec.rb
@@ -30,7 +30,7 @@ describe Gitlab::GithubImport::IssuableFinder, :clean_gitlab_redis_cache do
describe '#cache_database_id' do
it 'caches the ID of a database row' do
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:write)
.with('github-import/issuable-finder/4/MergeRequest/1', 10)
diff --git a/spec/lib/gitlab/github_import/label_finder_spec.rb b/spec/lib/gitlab/github_import/label_finder_spec.rb
index 039ae27ad57..bb946a15a2d 100644
--- a/spec/lib/gitlab/github_import/label_finder_spec.rb
+++ b/spec/lib/gitlab/github_import/label_finder_spec.rb
@@ -21,7 +21,7 @@ describe Gitlab::GithubImport::LabelFinder, :clean_gitlab_redis_cache do
it 'returns nil for an empty cache key' do
key = finder.cache_key_for(bug.name)
- Gitlab::GithubImport::Caching.write(key, '')
+ Gitlab::Cache::Import::Caching.write(key, '')
expect(finder.id_for(bug.name)).to be_nil
end
@@ -40,7 +40,7 @@ describe Gitlab::GithubImport::LabelFinder, :clean_gitlab_redis_cache do
describe '#build_cache' do
it 'builds the cache of all project labels' do
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:write_multiple)
.with(
{
diff --git a/spec/lib/gitlab/github_import/milestone_finder_spec.rb b/spec/lib/gitlab/github_import/milestone_finder_spec.rb
index 407e2e67ec9..ecb533b7e39 100644
--- a/spec/lib/gitlab/github_import/milestone_finder_spec.rb
+++ b/spec/lib/gitlab/github_import/milestone_finder_spec.rb
@@ -22,7 +22,7 @@ describe Gitlab::GithubImport::MilestoneFinder, :clean_gitlab_redis_cache do
it 'returns nil for an empty cache key' do
key = finder.cache_key_for(milestone.iid)
- Gitlab::GithubImport::Caching.write(key, '')
+ Gitlab::Cache::Import::Caching.write(key, '')
expect(finder.id_for(issuable)).to be_nil
end
@@ -41,7 +41,7 @@ describe Gitlab::GithubImport::MilestoneFinder, :clean_gitlab_redis_cache do
describe '#build_cache' do
it 'builds the cache of all project milestones' do
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:write_multiple)
.with("github-import/milestone-finder/#{project.id}/1" => milestone.id)
.and_call_original
diff --git a/spec/lib/gitlab/github_import/page_counter_spec.rb b/spec/lib/gitlab/github_import/page_counter_spec.rb
index 87f3ce45fd3..95125c9c22f 100644
--- a/spec/lib/gitlab/github_import/page_counter_spec.rb
+++ b/spec/lib/gitlab/github_import/page_counter_spec.rb
@@ -12,7 +12,7 @@ describe Gitlab::GithubImport::PageCounter, :clean_gitlab_redis_cache do
end
it 'sets the initial page number to the cached value when one is present' do
- Gitlab::GithubImport::Caching.write(counter.cache_key, 2)
+ Gitlab::Cache::Import::Caching.write(counter.cache_key, 2)
expect(described_class.new(project, :issues).current).to eq(2)
end
diff --git a/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb b/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb
index f4d107e3dce..a6ae99b395c 100644
--- a/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb
+++ b/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb
@@ -57,7 +57,7 @@ describe Gitlab::GithubImport::ParallelScheduling do
expect(importer).to receive(:parallel_import)
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:expire)
.with(importer.already_imported_cache_key, a_kind_of(Numeric))
@@ -287,7 +287,7 @@ describe Gitlab::GithubImport::ParallelScheduling do
.with(object)
.and_return(object.id)
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:set_add)
.with(importer.already_imported_cache_key, object.id)
.and_call_original
diff --git a/spec/lib/gitlab/github_import/user_finder_spec.rb b/spec/lib/gitlab/github_import/user_finder_spec.rb
index 74b5c1c52cd..8764ebef32b 100644
--- a/spec/lib/gitlab/github_import/user_finder_spec.rb
+++ b/spec/lib/gitlab/github_import/user_finder_spec.rb
@@ -162,7 +162,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
context 'when an Email address is cached' do
it 'reads the Email address from the cache' do
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:read)
.and_return(email)
@@ -182,7 +182,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
it 'caches the Email address when an Email address is available' do
expect(client).to receive(:user).with('kittens').and_return(user)
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:write)
.with(an_instance_of(String), email)
@@ -195,7 +195,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
.with('kittens')
.and_return(nil)
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.not_to receive(:write)
expect(finder.email_for_github_username('kittens')).to be_nil
@@ -207,7 +207,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
let(:id) { 4 }
it 'reads a user ID from the cache' do
- Gitlab::GithubImport::Caching
+ Gitlab::Cache::Import::Caching
.write(described_class::ID_CACHE_KEY % id, 4)
expect(finder.cached_id_for_github_id(id)).to eq([true, 4])
@@ -222,7 +222,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
let(:email) { 'kittens@example.com' }
it 'reads a user ID from the cache' do
- Gitlab::GithubImport::Caching
+ Gitlab::Cache::Import::Caching
.write(described_class::ID_FOR_EMAIL_CACHE_KEY % email, 4)
expect(finder.cached_id_for_github_email(email)).to eq([true, 4])
@@ -241,7 +241,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
.with(id)
.and_return(42)
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:write)
.with(described_class::ID_CACHE_KEY % id, 42)
@@ -253,7 +253,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
.with(id)
.and_return(nil)
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:write)
.with(described_class::ID_CACHE_KEY % id, nil)
@@ -269,7 +269,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
.with(email)
.and_return(42)
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:write)
.with(described_class::ID_FOR_EMAIL_CACHE_KEY % email, 42)
@@ -281,7 +281,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
.with(email)
.and_return(nil)
- expect(Gitlab::GithubImport::Caching)
+ expect(Gitlab::Cache::Import::Caching)
.to receive(:write)
.with(described_class::ID_FOR_EMAIL_CACHE_KEY % email, nil)
@@ -317,13 +317,13 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
describe '#read_id_from_cache' do
it 'reads an ID from the cache' do
- Gitlab::GithubImport::Caching.write('foo', 10)
+ Gitlab::Cache::Import::Caching.write('foo', 10)
expect(finder.read_id_from_cache('foo')).to eq([true, 10])
end
it 'reads a cache key with an empty value' do
- Gitlab::GithubImport::Caching.write('foo', nil)
+ Gitlab::Cache::Import::Caching.write('foo', nil)
expect(finder.read_id_from_cache('foo')).to eq([true, nil])
end