diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-13 23:24:28 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 12:48:17 +0100 |
commit | 0d6e7b9d3d38e60e5a706956a853e7dc940e4574 (patch) | |
tree | 8a0305f73a14a1884f788690f3ca434f4717991b /spec | |
parent | ad2b0358e0facd5c65c4141ce54c2e55bab165e6 (diff) | |
download | gitlab-ce-0d6e7b9d3d38e60e5a706956a853e7dc940e4574.tar.gz |
Use Hash to store paths and entries metadata in artifacts browser
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb | 58 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb | 16 |
2 files changed, 36 insertions, 38 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 a728227f87c..41257103ead 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb @@ -2,26 +2,26 @@ require 'spec_helper' 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/subdir/', - 'path/dir_1/subdir/subfile', - 'path/second_dir', - 'path/second_dir/dir_3/file_2', - 'path/second_dir/dir_3/file_3', - 'another_directory/', - 'another_file', - '/file/with/absolute_path'] + { 'path/' => {}, + 'path/dir_1/' => {}, + 'path/dir_1/file_1' => {}, + 'path/dir_1/file_b' => {}, + 'path/dir_1/subdir/' => {}, + 'path/dir_1/subdir/subfile' => {}, + 'path/second_dir' => {}, + 'path/second_dir/dir_3/file_2' => {}, + 'path/second_dir/dir_3/file_3'=> {}, + 'another_directory/'=> {}, + 'another_file' => {}, + '/file/with/absolute_path' => {} } end def path(example) - string_path(example.metadata[:path]) + entry(example.metadata[:path]) end - def string_path(string_path) - described_class.new(string_path, entries) + def entry(path) + described_class.new(path, entries) end describe '/file/with/absolute_path', path: '/file/with/absolute_path' do @@ -53,7 +53,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do describe '#parent' do subject { |example| path(example).parent } - it { is_expected.to eq string_path('path/') } + it { is_expected.to eq entry('path/') } end describe '#children' do @@ -61,9 +61,9 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do it { is_expected.to all(be_an_instance_of described_class) } it do - is_expected.to contain_exactly string_path('path/dir_1/file_1'), - string_path('path/dir_1/file_b'), - string_path('path/dir_1/subdir/') + is_expected.to contain_exactly entry('path/dir_1/file_1'), + entry('path/dir_1/file_b'), + entry('path/dir_1/subdir/') end end @@ -73,8 +73,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do it { is_expected.to all(be_file) } it { is_expected.to all(be_an_instance_of described_class) } it do - is_expected.to contain_exactly string_path('path/dir_1/file_1'), - string_path('path/dir_1/file_b') + is_expected.to contain_exactly entry('path/dir_1/file_1'), + entry('path/dir_1/file_b') end end @@ -84,7 +84,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do it { is_expected.to all(be_directory) } it { is_expected.to all(be_an_instance_of described_class) } - it { is_expected.to contain_exactly string_path('path/dir_1/subdir/') } + it { is_expected.to contain_exactly entry('path/dir_1/subdir/') } end context 'with option parent: true' do @@ -93,8 +93,8 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do it { is_expected.to all(be_directory) } it { is_expected.to all(be_an_instance_of described_class) } it do - is_expected.to contain_exactly string_path('path/dir_1/subdir/'), - string_path('path/') + is_expected.to contain_exactly entry('path/dir_1/subdir/'), + entry('path/') end end @@ -154,15 +154,13 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do describe '#metadata' do let(:entries) do - ['path/', 'path/file1', 'path/file2'] - end - - let(:metadata) do - [{ name: '/path/' }, { name: '/path/file1' }, { name: '/path/file2' }] + { 'path/' => { name: '/path/' }, + 'path/file1' => { name: '/path/file1' }, + 'path/file2' => { name: '/path/file2' } } end subject do - described_class.new('path/file1', entries, metadata).metadata[:name] + described_class.new('path/file1', entries).metadata[:name] end it { is_expected.to eq '/path/file1' } diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb index 8560493f5b5..828eedfa7b0 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb @@ -14,18 +14,18 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('').find_entries! } it 'matches correct paths' do - expect(subject.first).to contain_exactly 'ci_artifacts.txt', - 'other_artifacts_0.1.2/', - 'rails_sample.jpg', - 'tests_encoding/' + expect(subject.keys).to contain_exactly 'ci_artifacts.txt', + 'other_artifacts_0.1.2/', + 'rails_sample.jpg', + 'tests_encoding/' end it 'matches metadata for every path' do - expect(subject.last.count).to eq 4 + expect(subject.keys.count).to eq 4 end it 'return Hashes for each metadata' do - expect(subject.last).to all(be_kind_of(Hash)) + expect(subject.values).to all(be_kind_of(Hash)) end end @@ -33,7 +33,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/').find_entries! } it 'matches correct paths' do - expect(subject.first). + 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/' @@ -44,7 +44,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do subject { metadata('other_artifacts_0.1.2/another-subdirectory/').find_entries! } it 'matches correct paths' do - expect(subject.first). + expect(subject.keys). to contain_exactly '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' |