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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 21:09:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-12 21:09:28 +0300
commitce8a0b90849ac5d1895e741c023432930f24d724 (patch)
treedbdc97de542cdbe18a2fc8b1a6b64ac0673ed3d3 /spec/lib/gitlab/ci
parentdc889678d1de8c09310b2f8f9742bb6c78a6f1a4 (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.rb69
-rw-r--r--spec/lib/gitlab/ci/reports/test_case_spec.rb12
2 files changed, 81 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb
index b91cf1dd3ed..9a486c312d4 100644
--- a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb
+++ b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb
@@ -205,6 +205,75 @@ describe Gitlab::Ci::Parsers::Test::Junit do
end
end
+ context 'when data contains an attachment tag' do
+ let(:junit) do
+ <<~EOF
+ <testsuites>
+ <testsuite>
+ <testcase classname='Calculator' name='sumTest1' time='0.01'>
+ <failure>Some failure</failure>
+ <system-out>[[ATTACHMENT|some/path.png]]</system-out>
+ </testcase>
+ </testsuite>
+ </testsuites>
+ EOF
+ end
+
+ it 'add attachment to a 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")
+ end
+ end
+
+ context 'when data contains multiple attachments tag' do
+ let(:junit) do
+ <<~EOF
+ <testsuites>
+ <testsuite>
+ <testcase classname='Calculator' name='sumTest1' time='0.01'>
+ <failure>Some failure</failure>
+ <system-out>
+ [[ATTACHMENT|some/path.png]]
+ [[ATTACHMENT|some/path.html]]
+ </system-out>
+ </testcase>
+ </testsuite>
+ </testsuites>
+ EOF
+ end
+
+ it 'adds the first match attachment to a 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")
+ end
+ end
+
+ context 'when data does not match attachment tag regex' do
+ let(:junit) do
+ <<~EOF
+ <testsuites>
+ <testsuite>
+ <testcase classname='Calculator' name='sumTest1' time='0.01'>
+ <failure>Some failure</failure>
+ <system-out>[[attachment]some/path.png]]</system-out>
+ </testcase>
+ </testsuite>
+ </testsuites>
+ EOF
+ end
+
+ it 'does not add attachment to a test case' do
+ expect { subject }.not_to raise_error
+
+ expect(test_cases[0].has_attachment?).to be_falsy
+ expect(test_cases[0].attachment).to be_nil
+ end
+ end
+
private
def flattened_test_cases(test_suite)
diff --git a/spec/lib/gitlab/ci/reports/test_case_spec.rb b/spec/lib/gitlab/ci/reports/test_case_spec.rb
index 20c489ee94c..c13161f3e7c 100644
--- a/spec/lib/gitlab/ci/reports/test_case_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_case_spec.rb
@@ -88,5 +88,17 @@ describe Gitlab::Ci::Reports::TestCase do
expect { test_case }.to raise_error(ArgumentError)
end
end
+
+ context 'when attachment is present' do
+ let(:attachment_test_case) { build(:test_case, :with_attachment) }
+
+ it "initializes the attachment if present" do
+ expect(attachment_test_case.attachment).to eq("some/path.png")
+ end
+
+ it '#has_attachment?' do
+ expect(attachment_test_case.has_attachment?).to be_truthy
+ end
+ end
end
end