Merge "Tests: Add tests for duplicate views"

This commit is contained in:
Zuul 2023-02-05 10:52:34 +00:00 committed by Gerrit Code Review
commit f30550c290
34 changed files with 84 additions and 1 deletions

View File

@ -22,7 +22,7 @@ from jenkins_jobs.errors import JenkinsJobsException
from tests.enum_scenarios import scenario_list
fixtures_dir = Path(__file__).parent / "fixtures"
fixtures_dir = Path(__file__).parent / "job_fixtures"
@pytest.fixture(

View File

@ -0,0 +1,27 @@
from operator import attrgetter
from pathlib import Path
import pytest
from jenkins_jobs.errors import JenkinsJobsException
from tests.enum_scenarios import scenario_list
fixtures_dir = Path(__file__).parent / "view_fixtures"
@pytest.fixture(
params=scenario_list(fixtures_dir),
ids=attrgetter("name"),
)
def scenario(request):
return request.param
def test_yaml_snippet(scenario, check_view):
if scenario.in_path.name.startswith("exception_"):
with pytest.raises(JenkinsJobsException) as excinfo:
check_view()
assert str(excinfo.value).startswith("Duplicate ")
else:
check_view()

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<hudson.model.AllView>
<name>sample-template-1.1</name>
<description>Views for version 1.1&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>
<?xml version="1.0" encoding="utf-8"?>
<hudson.model.AllView>
<name>sample-template-2.0</name>
<description>Views for version 2.0&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
<filterExecutors>false</filterExecutors>
<filterQueue>false</filterQueue>
<properties class="hudson.model.View$PropertyList"/>
</hudson.model.AllView>

View File

@ -0,0 +1,12 @@
- view-template:
name: sample-template-{version}
view-type: all
description: 'Views for version {version}'
- project:
name: sample-project
version: 1.1
views:
- sample-template-{version}
- sample-template-{version}:
version: 2.0

View File

@ -0,0 +1,7 @@
- view:
name: duplicate-view
view-type: all
- view:
name: duplicate-view
view-type: all

View File

@ -0,0 +1,12 @@
- view-template:
name: duplicate-view-template
view-type: all
- view-template:
name: duplicate-view-template
view-type: all
- project:
name: sample-project
views:
- duplicate-view-template

View File

@ -0,0 +1,9 @@
- view-template:
name: sample-template
view-type: all
- project:
name: sample-project
views:
- sample-template
- sample-template