Skip to content

Commit 6c94baa

Browse files
authored
Add test that verifies history tables entries (#352)
It's easy to forget to add an entry in the history table when you copy an existing event definition file. We therefore add a Python test file with a short test that verifies that each event definition has a corresponding history table entry. The new test exposed to definition files without history tables so we had to correct them too.
1 parent 046ed2b commit 6c94baa

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

definitions/EiffelTestCaseFinishedEvent/1.0.0.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,8 @@ required:
118118
- links
119119
additionalProperties: false
120120
_links: {}
121-
_history: []
121+
_history:
122+
- version: 1.0.0
123+
introduced_in: '[edition-bordeaux](../../../tree/edition-bordeaux)'
124+
changes: Initial version.
122125
_examples: []

definitions/EiffelTestExecutionRecipeCollectionCreatedEvent/1.0.0.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,8 @@ required:
181181
- links
182182
additionalProperties: false
183183
_links: {}
184-
_history: []
184+
_history:
185+
- version: 1.0.0
186+
introduced_in: '[edition-bordeaux](../../../tree/edition-bordeaux)'
187+
changes: Initial version.
185188
_examples: []

test_definitions.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2023 Axis Communications AB.
2+
# For a full list of individual contributors, please see the commit history.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
import pathlib
17+
18+
import pytest
19+
20+
import definition_loader
21+
22+
23+
@pytest.mark.parametrize(
24+
"event_definition_path",
25+
pathlib.Path(".").glob("definitions/Eiffel*Event/*.yml"),
26+
)
27+
def test_history_table_contains_current_version(event_definition_path):
28+
definition = definition_loader.load(event_definition_path)
29+
event_type = event_definition_path.parent.name
30+
event_version = event_definition_path.stem
31+
assert [
32+
entry
33+
for entry in definition.get("_history", [])
34+
if entry.get("version") == event_version
35+
], f"History table entry missing for {event_type} {event_version}"

0 commit comments

Comments
 (0)