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-09-02 00:10:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-02 00:10:21 +0300
commit5b8f2c8a24237cc5b2e2ba365b79e6293b93e459 (patch)
tree6ce5ce8932acbe93832fc0476f323e95bbb7dd8f /spec/presenters
parent304e230182b74eb84833c60b50618a5f0d7e2f9a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/presenters')
-rw-r--r--spec/presenters/ci/pipeline_artifacts/code_coverage_presenter_spec.rb62
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/presenters/ci/pipeline_artifacts/code_coverage_presenter_spec.rb b/spec/presenters/ci/pipeline_artifacts/code_coverage_presenter_spec.rb
new file mode 100644
index 00000000000..e679f5fa144
--- /dev/null
+++ b/spec/presenters/ci/pipeline_artifacts/code_coverage_presenter_spec.rb
@@ -0,0 +1,62 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Ci::PipelineArtifacts::CodeCoveragePresenter do
+ let(:pipeline_artifact) { create(:ci_pipeline_artifact, :with_code_coverage_with_multiple_files) }
+
+ subject(:presenter) { described_class.new(pipeline_artifact) }
+
+ describe '#for_files' do
+ subject { presenter.for_files(filenames) }
+
+ context 'when code coverage has data' do
+ context 'when filenames is empty' do
+ let(:filenames) { %w() }
+
+ it 'returns hash without coverage' do
+ expect(subject).to match(files: {})
+ end
+ end
+
+ context 'when filenames do not match code coverage data' do
+ let(:filenames) { %w(demo.rb) }
+
+ it 'returns hash without coverage' do
+ expect(subject).to match(files: {})
+ end
+ end
+
+ context 'when filenames matches code coverage data' do
+ context 'when asking for one filename' do
+ let(:filenames) { %w(file_a.rb) }
+
+ it 'returns coverage for the given filename' do
+ expect(subject).to match(files: { "file_a.rb" => { "1" => 1, "2" => 1, "3" => 1 } })
+ end
+ end
+
+ context 'when asking for multiple filenames' do
+ let(:filenames) { %w(file_a.rb file_b.rb) }
+
+ it 'returns coverage for a the given filenames' do
+ expect(subject).to match(
+ files: {
+ "file_a.rb" => {
+ "1" => 1,
+ "2" => 1,
+ "3" => 1
+ },
+ "file_b.rb" => {
+ "1" => 0,
+ "2" => 0,
+ "3" => 0
+ }
+ }
+ )
+ end
+ end
+ end
+ end
+ end
+end