diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 09:08:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-26 09:08:40 +0300 |
commit | 116d4e56e83a1f408afe710ce070e699ba206475 (patch) | |
tree | cc62d3820d9bfa199061edfdef3a2f4bda140507 /spec/lib/gitlab/ci | |
parent | dddde902acfa6acfb11583c61faa67cc7c8d11b6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/parsers/test/junit_spec.rb | 11 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/reports/test_case_spec.rb | 20 |
2 files changed, 27 insertions, 4 deletions
diff --git a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb index 9a486c312d4..da168f6daad 100644 --- a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb +++ b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb @@ -4,10 +4,11 @@ require 'fast_spec_helper' describe Gitlab::Ci::Parsers::Test::Junit do describe '#parse!' do - subject { described_class.new.parse!(junit, test_suite) } + subject { described_class.new.parse!(junit, test_suite, args) } let(:test_suite) { Gitlab::Ci::Reports::TestSuite.new('rspec') } let(:test_cases) { flattened_test_cases(test_suite) } + let(:args) { { job: { id: 1, project: "project" } } } context 'when data is JUnit style XML' do context 'when there are no <testcases> in <testsuite>' do @@ -205,7 +206,7 @@ describe Gitlab::Ci::Parsers::Test::Junit do end end - context 'when data contains an attachment tag' do + context 'when attachment is specified in failed test case' do let(:junit) do <<~EOF <testsuites> @@ -219,11 +220,15 @@ describe Gitlab::Ci::Parsers::Test::Junit do EOF end - it 'add attachment to a test case' do + it 'assigns correct attributes to the test case' do expect { subject }.not_to raise_error expect(test_cases[0].has_attachment?).to be_truthy expect(test_cases[0].attachment).to eq("some/path.png") + + expect(test_cases[0].job).to be_present + expect(test_cases[0].job[:id]).to eq(1) + expect(test_cases[0].job[:project]).to eq("project") end end diff --git a/spec/lib/gitlab/ci/reports/test_case_spec.rb b/spec/lib/gitlab/ci/reports/test_case_spec.rb index c13161f3e7c..69fe05d573e 100644 --- a/spec/lib/gitlab/ci/reports/test_case_spec.rb +++ b/spec/lib/gitlab/ci/reports/test_case_spec.rb @@ -15,7 +15,8 @@ describe Gitlab::Ci::Reports::TestCase do file: 'spec/trace_spec.rb', execution_time: 1.23, status: described_class::STATUS_SUCCESS, - system_output: nil + system_output: nil, + job: build(:ci_build) } end @@ -28,6 +29,7 @@ describe Gitlab::Ci::Reports::TestCase do expect(test_case.execution_time).to eq(1.23) expect(test_case.status).to eq(described_class::STATUS_SUCCESS) expect(test_case.system_output).to be_nil + expect(test_case.job).to be_present end end @@ -99,6 +101,22 @@ describe Gitlab::Ci::Reports::TestCase do it '#has_attachment?' do expect(attachment_test_case.has_attachment?).to be_truthy end + + it '#attachment_url' do + expect(attachment_test_case.attachment_url).to match(/file\/some\/path.png/) + end + end + + context 'when attachment is missing' do + let(:test_case) { build(:test_case) } + + it '#has_attachment?' do + expect(test_case.has_attachment?).to be_falsy + end + + it '#attachment_url' do + expect(test_case.attachment_url).to be_nil + end end end end |