diff options
Diffstat (limited to 'spec/lib/gitlab/ci/build')
-rw-r--r-- | spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb (renamed from spec/lib/gitlab/ci/build/artifacts/gzip_file_adapter_spec.rb) | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb | 47 |
2 files changed, 48 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ci/build/artifacts/gzip_file_adapter_spec.rb b/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb index 384329dda18..987c6b37aaa 100644 --- a/spec/lib/gitlab/ci/build/artifacts/gzip_file_adapter_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Gitlab::Ci::Build::Artifacts::GzipFileAdapter do +describe Gitlab::Ci::Build::Artifacts::Adapters::GzipStream do describe '#initialize' do context 'when stream is passed' do let(:stream) { File.open(expand_fixture_path('junit/junit.xml.gz'), 'rb') } diff --git a/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb b/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb new file mode 100644 index 00000000000..ec2dd724b45 --- /dev/null +++ b/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' + +describe Gitlab::Ci::Build::Artifacts::Adapters::RawStream do + describe '#initialize' do + context 'when stream is passed' do + let(:stream) { File.open(expand_fixture_path('junit/junit.xml'), 'rb') } + + it 'initialized' do + expect { described_class.new(stream) }.not_to raise_error + end + end + + context 'when stream is not passed' do + let(:stream) { nil } + + it 'raises an error' do + expect { described_class.new(stream) }.to raise_error(described_class::InvalidStreamError) + end + end + end + + describe '#each_blob' do + let(:adapter) { described_class.new(stream) } + + context 'when file is not empty' do + let(:stream) { File.open(expand_fixture_path('junit/junit.xml'), 'rb') } + + it 'iterates content' do + expect { |b| adapter.each_blob(&b) } + .to yield_with_args(fixture_file('junit/junit.xml'), 'raw') + end + end + + context 'when file is empty' do + let(:stream) { Tempfile.new } + + after do + stream.unlink + end + + it 'does not iterate content' do + expect { |b| adapter.each_blob(&b) } + .not_to yield_control + end + end + end +end |