|
2 | 2 | from ruamel.yaml import YAML
|
3 | 3 |
|
4 | 4 | from chartpress import _check_call
|
| 5 | +from chartpress import _fix_chart_version |
5 | 6 | from chartpress import _get_git_remote_url
|
6 | 7 | from chartpress import _get_identifier_from_parts
|
7 | 8 | from chartpress import _get_image_build_args
|
8 | 9 | from chartpress import _get_latest_commit_tagged_or_modifying_paths
|
9 | 10 | from chartpress import _image_needs_pushing
|
10 |
| -from chartpress import Builder |
11 | 11 | from chartpress import GITHUB_ACTOR_KEY
|
12 | 12 | from chartpress import GITHUB_TOKEN_KEY
|
| 13 | +from chartpress import yaml |
13 | 14 |
|
14 |
| -# use safe roundtrip yaml loader |
15 |
| -yaml = YAML(typ="rt") |
16 |
| -yaml.preserve_quotes = True ## avoid mangling of quotes |
17 |
| -yaml.indent(mapping=2, offset=2, sequence=4) |
18 | 15 |
|
19 |
| - |
20 |
| -def test__get_identifier_from_parts(): |
21 |
| - assert ( |
22 |
| - _get_identifier_from_parts( |
23 |
| - tag="0.1.2", n_commits="0", commit="asdf123", long=True |
24 |
| - ) |
25 |
| - == "0.1.2-n000.hasdf123" |
26 |
| - ) |
27 |
| - assert ( |
28 |
| - _get_identifier_from_parts( |
29 |
| - tag="0.1.2", n_commits="0", commit="asdf123", long=False |
30 |
| - ) |
31 |
| - == "0.1.2" |
32 |
| - ) |
33 |
| - assert ( |
34 |
| - _get_identifier_from_parts( |
35 |
| - tag="0.1.2", n_commits="5", commit="asdf123", long=False |
36 |
| - ) |
37 |
| - == "0.1.2-n005.hasdf123" |
38 |
| - ) |
39 |
| - assert ( |
40 |
| - _get_identifier_from_parts( |
41 |
| - tag="0.1.2-alpha.1", n_commits="0", commit="asdf1234", long=True |
42 |
| - ) |
43 |
| - == "0.1.2-alpha.1.n000.hasdf1234" |
44 |
| - ) |
45 |
| - assert ( |
46 |
| - _get_identifier_from_parts( |
47 |
| - tag="0.1.2-alpha.1", n_commits="0", commit="asdf1234", long=False |
48 |
| - ) |
49 |
| - == "0.1.2-alpha.1" |
50 |
| - ) |
51 |
| - assert ( |
52 |
| - _get_identifier_from_parts( |
53 |
| - tag="0.1.2-alpha.1", n_commits="5", commit="asdf1234", long=False |
54 |
| - ) |
55 |
| - == "0.1.2-alpha.1.n005.hasdf1234" |
| 16 | +@pytest.mark.parametrize( |
| 17 | + "tag, n_commits, commit, long, expected", |
| 18 | + [ |
| 19 | + ("0.1.2", "0", "asdf123", True, "0.1.2-0git.0.hasdf123"), |
| 20 | + ("0.1.2", "0", "asdf123", False, "0.1.2"), |
| 21 | + ("0.1.2", "5", "asdf123", False, "0.1.2-0git.5.hasdf123"), |
| 22 | + ("0.1.2-alpha.1", "0", "asdf1234", True, "0.1.2-alpha.1.0git.0.hasdf1234"), |
| 23 | + ("0.1.2-alpha.1", "0", "asdf1234", False, "0.1.2-alpha.1"), |
| 24 | + ("0.1.2-alpha.1", "5", "asdf1234", False, "0.1.2-alpha.1.0git.5.hasdf1234"), |
| 25 | + ], |
| 26 | +) |
| 27 | +def test_get_identifier_from_parts(tag, n_commits, commit, long, expected): |
| 28 | + tag = _get_identifier_from_parts( |
| 29 | + tag=tag, n_commits=n_commits, commit=commit, long=long |
56 | 30 | )
|
| 31 | + assert tag == expected |
| 32 | + _fix_chart_version(tag, strict=True) |
57 | 33 |
|
58 | 34 |
|
59 | 35 | def test__get_git_remote_url(monkeypatch):
|
|
0 commit comments