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
path: root/spec
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-01-04 15:08:49 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-01-14 14:48:15 +0300
commita7f99b67a0bf1160f41ebf4dc92c618eb13a7a10 (patch)
treefaba38ae6a6fcadb57fe564891912d37bed462ba /spec
parentdf41148662142ce20a77b092665f48dd4dfa7bfb (diff)
Extract artifacts metadata implementation to separate class
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb76
1 files changed, 76 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
new file mode 100644
index 00000000000..8c648be5f02
--- /dev/null
+++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
@@ -0,0 +1,76 @@
+require 'spec_helper'
+
+describe Gitlab::Ci::Build::Artifacts::Metadata do
+ def metadata(path = '')
+ described_class.new(metadata_file_path, path)
+ end
+
+ let(:metadata_file_path) do
+ Rails.root + 'spec/fixtures/ci_build_artifacts_metadata.gz'
+ end
+
+ context 'metadata file exists' do
+ describe '#exists?' do
+ subject { metadata.exists? }
+ it { is_expected.to be true }
+ end
+
+ describe '#match! ./' do
+ subject { metadata('./').match! }
+
+ it 'matches correct paths' do
+ expect(subject.first).to contain_exactly 'ci_artifacts.txt',
+ 'other_artifacts_0.1.2/',
+ 'rails_sample.jpg'
+ end
+
+ it 'matches metadata for every path' do
+ expect(subject.last.count).to eq 3
+ end
+
+ it 'return Hashes for each metadata' do
+ expect(subject.last).to all(be_kind_of(Hash))
+ end
+ end
+
+ describe '#match! other_artifacts_0.1.2' do
+ subject { metadata('other_artifacts_0.1.2').match! }
+
+ it 'matches correct paths' do
+ expect(subject.first).
+ to contain_exactly 'other_artifacts_0.1.2/doc_sample.txt',
+ 'other_artifacts_0.1.2/another-subdirectory/'
+ end
+ end
+
+ describe '#match! other_artifacts_0.1.2/another-subdirectory' do
+ subject { metadata('other_artifacts_0.1.2/another-subdirectory/').match! }
+
+ it 'matches correct paths' do
+ expect(subject.first).
+ to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
+ 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
+ end
+ end
+
+ describe '#to_string_path' do
+ subject { metadata('').to_string_path }
+ it { is_expected.to be_an_instance_of(Gitlab::StringPath) }
+ end
+ end
+
+ context 'metadata file does not exist' do
+ let(:metadata_file_path) { '' }
+
+ describe '#exists?' do
+ subject { metadata.exists? }
+ it { is_expected.to be false }
+ end
+
+ describe '#match!' do
+ it 'raises error' do
+ expect { metadata.match! }.to raise_error(StandardError, /Metadata file not found/)
+ end
+ end
+ end
+end