diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-05 16:54:15 +0300 |
commit | be834a25982746ffd85252ff502df42bb88cb9d5 (patch) | |
tree | b4d6a8ba0931e12fac08f05abea33a3b8ec2c8a2 /spec/lib/gitlab/manifest_import | |
parent | ee925a3597f27e92f83a50937a64068109675b3d (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc32
Diffstat (limited to 'spec/lib/gitlab/manifest_import')
-rw-r--r-- | spec/lib/gitlab/manifest_import/manifest_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/gitlab/manifest_import/metadata_spec.rb | 62 |
2 files changed, 63 insertions, 13 deletions
diff --git a/spec/lib/gitlab/manifest_import/manifest_spec.rb b/spec/lib/gitlab/manifest_import/manifest_spec.rb index 2e8753b0880..352120c079d 100644 --- a/spec/lib/gitlab/manifest_import/manifest_spec.rb +++ b/spec/lib/gitlab/manifest_import/manifest_spec.rb @@ -12,19 +12,7 @@ RSpec.describe Gitlab::ManifestImport::Manifest do end context 'missing or invalid attributes' do - let(:file) { Tempfile.new('foo') } - - before do - content = <<~EOS - <manifest> - <remote review="invalid-url" /> - <project name="platform/build"/> - </manifest> - EOS - - file.write(content) - file.rewind - end + let(:file) { File.open(Rails.root.join('spec/fixtures/invalid_manifest.xml')) } it { expect(manifest.valid?).to be false } diff --git a/spec/lib/gitlab/manifest_import/metadata_spec.rb b/spec/lib/gitlab/manifest_import/metadata_spec.rb new file mode 100644 index 00000000000..c8158d3e148 --- /dev/null +++ b/spec/lib/gitlab/manifest_import/metadata_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::ManifestImport::Metadata, :clean_gitlab_redis_shared_state do + let(:user) { double(id: 1) } + let(:repositories) do + [ + { id: 'test1', url: 'http://demo.host/test1' }, + { id: 'test2', url: 'http://demo.host/test2' } + ] + end + + describe '#save' do + it 'stores data in Redis with an expiry of EXPIRY_TIME' do + status = described_class.new(user) + repositories_key = 'manifest_import:metadata:user:1:repositories' + group_id_key = 'manifest_import:metadata:user:1:group_id' + + status.save(repositories, 2) + + Gitlab::Redis::SharedState.with do |redis| + expect(redis.ttl(repositories_key)).to be_within(5).of(described_class::EXPIRY_TIME) + expect(redis.ttl(group_id_key)).to be_within(5).of(described_class::EXPIRY_TIME) + end + end + end + + describe '#repositories' do + it 'allows repositories to round-trip with symbol keys' do + status = described_class.new(user) + + status.save(repositories, 2) + + expect(status.repositories).to eq(repositories) + end + + it 'uses the fallback when there is nothing in Redis' do + fallback = { manifest_import_repositories: repositories } + status = described_class.new(user, fallback: fallback) + + expect(status.repositories).to eq(repositories) + end + end + + describe '#group_id' do + it 'returns the group ID as an integer' do + status = described_class.new(user) + + status.save(repositories, 2) + + expect(status.group_id).to eq(2) + end + + it 'uses the fallback when there is nothing in Redis' do + fallback = { manifest_import_group_id: 3 } + status = described_class.new(user, fallback: fallback) + + expect(status.group_id).to eq(3) + end + end +end |