(
tmp_path_factory: pytest.TempPathFactory,
cli: bool,
)
| 1732 | |
| 1733 | @pytest.mark.parametrize("cli", [True, False]) |
| 1734 | def test_update_vcs_ref_current( |
| 1735 | tmp_path_factory: pytest.TempPathFactory, |
| 1736 | cli: bool, |
| 1737 | ) -> None: |
| 1738 | src, dst = map(tmp_path_factory.mktemp, ("src", "dst")) |
| 1739 | |
| 1740 | with local.cwd(src): |
| 1741 | build_file_tree( |
| 1742 | { |
| 1743 | "copier.yml": "boolean: false", |
| 1744 | "{{ _copier_conf.answers_file }}.jinja": "{{ _copier_answers|to_nice_yaml }}", |
| 1745 | } |
| 1746 | ) |
| 1747 | git_init("v1") |
| 1748 | git("tag", "v1") |
| 1749 | |
| 1750 | if cli: |
| 1751 | CopierApp.run( |
| 1752 | ["copier", "copy", str(src), str(dst), "--defaults", "--overwrite"], |
| 1753 | exit=False, |
| 1754 | ) |
| 1755 | else: |
| 1756 | run_copy(str(src), dst, defaults=True, overwrite=True) |
| 1757 | answers = load_answersfile_data(dst) |
| 1758 | assert answers["_commit"] == "v1" |
| 1759 | assert answers["boolean"] is False |
| 1760 | |
| 1761 | with local.cwd(dst): |
| 1762 | git_init("v1") |
| 1763 | |
| 1764 | with local.cwd(src): |
| 1765 | build_file_tree({"README.md": "# Template Update"}) |
| 1766 | git_save(message="update template", tag="v2") |
| 1767 | |
| 1768 | if cli: |
| 1769 | with local.cwd(dst): |
| 1770 | CopierApp.run( |
| 1771 | [ |
| 1772 | "copier", |
| 1773 | "update", |
| 1774 | "--data", |
| 1775 | "boolean=true", |
| 1776 | "--vcs-ref=:current:", |
| 1777 | ], |
| 1778 | exit=False, |
| 1779 | ) |
| 1780 | else: |
| 1781 | run_update( |
| 1782 | dst, data={"boolean": "true"}, vcs_ref=VcsRef.CURRENT, overwrite=True |
| 1783 | ) |
| 1784 | answers = load_answersfile_data(dst) |
| 1785 | assert answers["_commit"] == "v1" |
| 1786 | assert answers["boolean"] is True |
| 1787 | |
| 1788 | # assert that the README.md file was not created |
| 1789 | assert not (dst / "README.md").exists() |
| 1790 | |
| 1791 |
nothing calls this directly
no test coverage detected