BigW Consortium Gitlab

Commit 8527f3fa by Grzegorz Bizon

Update coverage report badge feature tests

parent 804474d7
...@@ -4,12 +4,6 @@ feature 'test coverage badge' do ...@@ -4,12 +4,6 @@ feature 'test coverage badge' do
given!(:user) { create(:user) } given!(:user) { create(:user) }
given!(:project) { create(:project, :private) } given!(:project) { create(:project, :private) }
given!(:pipeline) do
create(:ci_pipeline, project: project,
ref: 'master',
sha: project.commit.id)
end
context 'when user has access to view badge' do context 'when user has access to view badge' do
background do background do
project.team << [user, :developer] project.team << [user, :developer]
...@@ -17,8 +11,10 @@ feature 'test coverage badge' do ...@@ -17,8 +11,10 @@ feature 'test coverage badge' do
end end
scenario 'user requests coverage badge image for pipeline' do scenario 'user requests coverage badge image for pipeline' do
create_job(coverage: 100, name: 'test:1') create_pipeline do |pipeline|
create_job(coverage: 90, name: 'test:2') create_build(pipeline, coverage: 100, name: 'test:1')
create_build(pipeline, coverage: 90, name: 'test:2')
end
show_test_coverage_badge show_test_coverage_badge
...@@ -26,9 +22,11 @@ feature 'test coverage badge' do ...@@ -26,9 +22,11 @@ feature 'test coverage badge' do
end end
scenario 'user requests coverage badge for specific job' do scenario 'user requests coverage badge for specific job' do
create_job(coverage: 50, name: 'test:1') create_pipeline do |pipeline|
create_job(coverage: 50, name: 'test:2') create_build(pipeline, coverage: 50, name: 'test:1')
create_job(coverage: 85, name: 'coverage') create_build(pipeline, coverage: 50, name: 'test:2')
create_build(pipeline, coverage: 85, name: 'coverage')
end
show_test_coverage_badge(job: 'coverage') show_test_coverage_badge(job: 'coverage')
...@@ -36,7 +34,9 @@ feature 'test coverage badge' do ...@@ -36,7 +34,9 @@ feature 'test coverage badge' do
end end
scenario 'user requests coverage badge for pipeline without coverage' do scenario 'user requests coverage badge for pipeline without coverage' do
create_job(coverage: nil, name: 'test') create_pipeline do |pipeline|
create_build(pipeline, coverage: nil, name: 'test')
end
show_test_coverage_badge show_test_coverage_badge
...@@ -54,10 +54,19 @@ feature 'test coverage badge' do ...@@ -54,10 +54,19 @@ feature 'test coverage badge' do
end end
end end
def create_job(coverage:, name:) def create_pipeline
create(:ci_build, name: name, opts = { project: project, ref: 'master', sha: project.commit.id }
coverage: coverage,
pipeline: pipeline) create(:ci_pipeline, opts).tap do |pipeline|
yield pipeline
pipeline.build_updated
end
end
def create_build(pipeline, coverage:, name:)
opts = { pipeline: pipeline, coverage: coverage, name: name }
create(:ci_build, :success, opts)
end end
def show_test_coverage_badge(job: nil) def show_test_coverage_badge(job: nil)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment