|
1 | 1 | import pytest |
2 | 2 |
|
3 | 3 | from exasol.toolbox.tools.replace_version import ( |
4 | | - is_update_required, |
5 | | - update_version, |
| 4 | + _update_line_with_version, |
6 | 5 | update_versions, |
7 | 6 | ) |
8 | 7 |
|
9 | 8 |
|
10 | 9 | @pytest.mark.parametrize( |
11 | | - "line,matcher,expected", |
| 10 | + "line,expected", |
12 | 11 | [ |
13 | | - ("hallo/world@all", "hallo", True), |
14 | | - ("hallo/world@all", "foo", False), |
15 | | - ("hallo/world/all", "hallo", False), |
16 | | - ("hallo/world/all", "foo", False), |
| 12 | + pytest.param( |
| 13 | + "exasol/python-toolbox/.github/actions/python-environment@1.0.0", |
| 14 | + "exasol/python-toolbox/.github/actions/python-environment@2.0.0", |
| 15 | + id="github_action", |
| 16 | + ), |
| 17 | + pytest.param( |
| 18 | + "pip install exasol-toolbox==1.0.0\n", |
| 19 | + "pip install exasol-toolbox==2.0.0\n", |
| 20 | + id="pypi_version", |
| 21 | + ), |
| 22 | + pytest.param( |
| 23 | + "- name: Create Security Issue Report", |
| 24 | + "- name: Create Security Issue Report", |
| 25 | + id="no_change_expected", |
| 26 | + ), |
17 | 27 | ], |
18 | 28 | ) |
19 | | -def test_is_update_required(line, matcher, expected): |
20 | | - actual = is_update_required(line, matcher) |
| 29 | +def test_update_line_with_version(line: str, expected: str): |
| 30 | + actual = _update_line_with_version(line=line, version="2.0.0") |
21 | 31 | assert actual == expected |
22 | 32 |
|
23 | 33 |
|
24 | 34 | @pytest.mark.parametrize( |
25 | | - "line,version,expected", |
| 35 | + "line_to_change, expected", |
26 | 36 | [ |
27 | | - ("hallo/world@1.2.3\n", "2.3.4", "hallo/world@2.3.4\n"), |
28 | | - ("hallo/world@0.0.0\n", "9.9.9", "hallo/world@9.9.9\n"), |
| 37 | + pytest.param( |
| 38 | + "exasol/python-toolbox/.github/actions/python-environment@1.0.0", |
| 39 | + "exasol/python-toolbox/.github/actions/python-environment@2.0.0", |
| 40 | + id="github_action", |
| 41 | + ), |
| 42 | + pytest.param( |
| 43 | + "pip install exasol-toolbox==1.0.0\n", |
| 44 | + "pip install exasol-toolbox==2.0.0\n", |
| 45 | + id="pypi_version", |
| 46 | + ), |
29 | 47 | ], |
30 | 48 | ) |
31 | | -def test_update_version(line, version, expected): |
32 | | - actual = update_version(line, version) |
33 | | - assert actual == expected |
34 | | - |
| 49 | +def test_update_versions(line_to_change, expected): |
| 50 | + dummy_lines = [ |
| 51 | + "exasol/python-toolbox/.github/actions/python-environment@dummy\n", |
| 52 | + "- name: Create Security Issue Report\n", |
| 53 | + "pip install exasol-toolbox==dummy\n", |
| 54 | + ] |
| 55 | + lines = dummy_lines + [line_to_change] |
| 56 | + expected_lines = dummy_lines + [expected] |
35 | 57 |
|
36 | | -@pytest.mark.parametrize( |
37 | | - "lines,matcher,version,expected", |
38 | | - [ |
39 | | - ( |
40 | | - [ |
41 | | - "hallo/world@3.4.5\n", |
42 | | - "foo/world@3.4.5\n", |
43 | | - "hallo/world/3.4.5\n", |
44 | | - "foo/world/3.4.5\n", |
45 | | - ], |
46 | | - "hallo", |
47 | | - "4.5.6", |
48 | | - [ |
49 | | - "hallo/world@4.5.6\n", |
50 | | - "foo/world@3.4.5\n", |
51 | | - "hallo/world/3.4.5\n", |
52 | | - "foo/world/3.4.5\n", |
53 | | - ], |
54 | | - ) |
55 | | - ], |
56 | | -) |
57 | | -def test_update_versions(lines, matcher, version, expected): |
58 | | - actual = update_versions(lines, matcher, version) |
59 | | - assert actual == expected |
| 58 | + actual = update_versions(lines=lines, version="2.0.0") |
| 59 | + assert actual == expected_lines |
0 commit comments