diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 15:07:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 15:07:48 +0300 |
commit | ef31adeb0fb9a02b2c6a4529ec4e38d7082a4b2b (patch) | |
tree | f0ee2b8bdffd7f91ad0b31388562c90825179585 /spec/lib/gitlab/jira_import_spec.rb | |
parent | 7e019504f5ac6decde690565857238e7e59aa034 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/jira_import_spec.rb')
-rw-r--r-- | spec/lib/gitlab/jira_import_spec.rb | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/lib/gitlab/jira_import_spec.rb b/spec/lib/gitlab/jira_import_spec.rb new file mode 100644 index 00000000000..c5c3d6ef4b9 --- /dev/null +++ b/spec/lib/gitlab/jira_import_spec.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::JiraImport do + let(:project_id) { 321 } + + describe '.jira_issue_cache_key' do + it 'returns cache key for Jira issue imported to given project' do + expect(described_class.jira_issue_cache_key(project_id, 'DEMO-123')).to eq("jira-import/items-mapper/#{project_id}/issues/DEMO-123") + end + end + + describe '.already_imported_cache_key' do + it 'returns cache key for already imported items' do + expect(described_class.already_imported_cache_key(:issues, project_id)).to eq("jira-importer/already-imported/#{project_id}/issues") + end + end + + describe '.jira_issues_next_page_cache_key' do + it 'returns cache key for next issues' do + expect(described_class.jira_issues_next_page_cache_key(project_id)).to eq("jira-import/paginator/#{project_id}/issues") + end + end + + describe '.get_issues_next_start_at', :clean_gitlab_redis_cache do + it 'returns zero when not defined' do + expect(Gitlab::Cache::Import::Caching.read("jira-import/paginator/#{project_id}/issues")).to be nil + expect(described_class.get_issues_next_start_at(project_id)).to eq(0) + end + + it 'returns negative value for next issues to be imported starting point' do + Gitlab::Cache::Import::Caching.write("jira-import/paginator/#{project_id}/issues", -10) + + expect(Gitlab::Cache::Import::Caching.read("jira-import/paginator/#{project_id}/issues")).to eq('-10') + expect(described_class.get_issues_next_start_at(project_id)).to eq(-10) + end + + it 'returns cached value for next issues to be imported starting point' do + Gitlab::Cache::Import::Caching.write("jira-import/paginator/#{project_id}/issues", 10) + + expect(Gitlab::Cache::Import::Caching.read("jira-import/paginator/#{project_id}/issues")).to eq('10') + expect(described_class.get_issues_next_start_at(project_id)).to eq(10) + end + end + + describe '.store_issues_next_started_at', :clean_gitlab_redis_cache do + it 'stores nil value' do + described_class.store_issues_next_started_at(project_id, nil) + + expect(Gitlab::Cache::Import::Caching.read("jira-import/paginator/#{project_id}/issues")).to eq '' + expect(Gitlab::Cache::Import::Caching.read("jira-import/paginator/#{project_id}/issues").to_i).to eq(0) + end + + it 'stores positive value' do + described_class.store_issues_next_started_at(project_id, 10) + + expect(Gitlab::Cache::Import::Caching.read("jira-import/paginator/#{project_id}/issues").to_i).to eq(10) + end + + it 'stores negative value' do + described_class.store_issues_next_started_at(project_id, -10) + + expect(Gitlab::Cache::Import::Caching.read("jira-import/paginator/#{project_id}/issues").to_i).to eq(-10) + end + end +end |