summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-01-20 21:48:22 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2016-01-20 21:55:13 +0100
commit9b0f57781e8c71eb0e627a63078fedcedfe62bbb (patch)
treec9e9708a8740e1f215a7ba08d97736bc29162c27 /spec/lib
parent425f8d6f572a3ae47c971a48bfefc9907c7bda55 (diff)
downloadgitlab-ce-9b0f57781e8c71eb0e627a63078fedcedfe62bbb.tar.gz
Add method that calculates total size for artifacts subfolderci/recursive-artifacts-entries
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb15
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb17
2 files changed, 25 insertions, 7 deletions
diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb
index 41257103ead..acca0b08bab 100644
--- a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb
+++ b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb
@@ -4,13 +4,13 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
let(:entries) do
{ 'path/' => {},
'path/dir_1/' => {},
- 'path/dir_1/file_1' => {},
- 'path/dir_1/file_b' => {},
+ 'path/dir_1/file_1' => { size: 10 },
+ 'path/dir_1/file_b' => { size: 10 },
'path/dir_1/subdir/' => {},
- 'path/dir_1/subdir/subfile' => {},
+ 'path/dir_1/subdir/subfile' => { size: 10 },
'path/second_dir' => {},
- 'path/second_dir/dir_3/file_2' => {},
- 'path/second_dir/dir_3/file_3'=> {},
+ 'path/second_dir/dir_3/file_2' => { size: 10 },
+ 'path/second_dir/dir_3/file_3'=> { size: 10 },
'another_directory/'=> {},
'another_file' => {},
'/file/with/absolute_path' => {} }
@@ -112,6 +112,11 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
subject { |example| path(example).empty? }
it { is_expected.to be false }
end
+
+ describe '#total_size' do
+ subject { |example| path(example).total_size }
+ it { is_expected.to eq(30) }
+ end
end
end
diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
index 828eedfa7b0..eea01f91879 100644
--- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
+++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
@@ -1,8 +1,8 @@
require 'spec_helper'
describe Gitlab::Ci::Build::Artifacts::Metadata do
- def metadata(path = '')
- described_class.new(metadata_file_path, path)
+ def metadata(path = '', **opts)
+ described_class.new(metadata_file_path, path, **opts)
end
let(:metadata_file_path) do
@@ -51,6 +51,19 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
end
end
+ describe '#find_entries! recursively for other_artifacts_0.1.2/' do
+ subject { metadata('other_artifacts_0.1.2/', recursive: true).find_entries! }
+
+ it 'matches correct paths' do
+ expect(subject.keys).
+ to contain_exactly 'other_artifacts_0.1.2/',
+ 'other_artifacts_0.1.2/doc_sample.txt',
+ 'other_artifacts_0.1.2/another-subdirectory/',
+ 'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
+ 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
+ end
+ end
+
describe '#to_entry' do
subject { metadata('').to_entry }
it { is_expected.to be_an_instance_of(Gitlab::Ci::Build::Artifacts::Metadata::Entry) }