Coverage for tests/test_jaypore_ci.py: 98%
77 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-30 09:04 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-30 09:04 +0000
1import pytest
2from jaypore_ci.changelog import version_map
3from jaypore_ci.config import const
6def test_sanity():
7 assert 4 == 2 + 2
10def test_version_has_entry_in_version_map():
11 assert const.version in version_map, const
14def test_simple_linear_jobs(pipeline):
15 pipeline = pipeline()
16 with pipeline as p:
17 p.job("lint", "x")
18 p.job("test", "x", depends_on=["lint"])
19 order = pipeline.executor.get_execution_order()
20 assert order["lint"] < order["test"]
23def test_no_duplicate_names(pipeline):
24 pipeline = pipeline()
25 with pytest.raises(AssertionError):
26 with pipeline as p:
27 p.job("lint", "x")
28 p.job("lint", "y")
31def test_dependency_has_to_be_defined_before_child(pipeline):
32 pipeline = pipeline()
33 with pytest.raises(AssertionError):
34 with pipeline as p:
35 p.job("x", "x", depends_on=["y"])
36 p.job("y", "y")
39def test_dependency_cannot_cross_stages(pipeline):
40 pipeline = pipeline()
41 with pytest.raises(AssertionError):
42 with pipeline as p:
43 with p.stage("stage1"):
44 p.job("y", "y")
45 with p.stage("stage2"):
46 p.job("x", "x", depends_on=["y"])
49def test_duplicate_stages_not_allowed(pipeline):
50 pipeline = pipeline()
51 with pytest.raises(AssertionError):
52 with pipeline as p:
53 with p.stage("stage1"):
54 p.job("x", "x")
55 with p.stage("stage1"): 55 ↛ 56line 55 didn't jump to line 56
56 p.job("y", "y")
59def test_stage_and_job_cannot_have_same_name(pipeline):
60 pipeline = pipeline()
61 with pytest.raises(AssertionError):
62 with pipeline as p:
63 with p.stage("x"):
64 p.job("x", "x")
67def test_cannot_define_duplicate_jobs(pipeline):
68 pipeline = pipeline()
69 with pytest.raises(AssertionError):
70 with pipeline as p:
71 p.job("x", "x")
72 p.job("x", "x")
75def test_non_service_jobs_must_have_commands(pipeline):
76 pipeline = pipeline()
77 with pytest.raises(AssertionError):
78 with pipeline as p:
79 p.job("x", None)
82def test_call_chain_is_followed(pipeline):
83 pipeline = pipeline()
84 with pipeline as p:
85 for name in "pq":
86 p.job(name, name)
87 p.job("x", "x")
88 p.job("y", "y", depends_on=["x"])
89 p.job("z", "z", depends_on=["y"])
90 for name in "ab":
91 p.job(name, name)
92 order = pipeline.executor.get_execution_order()
93 # assert order == {}
94 assert order["x"] < order["y"] < order["z"]
97def test_env_matrix_is_easy_to_make(pipeline):
98 pipeline = pipeline()
99 with pipeline as p:
100 for i, env in enumerate(p.env_matrix(A=[1, 2, 3], B=[5, 6, 7])):
101 p.job(f"job{i}", "fake command", env=env)
102 assert len(pipeline.jobs) == 9