MCPcopy
hub / github.com/copier-org/copier / test_update_vcs_ref_current

Function test_update_vcs_ref_current

tests/test_updatediff.py:1734–1789  ·  view source on GitHub ↗
(
    tmp_path_factory: pytest.TempPathFactory,
    cli: bool,
)

Source from the content-addressed store, hash-verified

1732
1733@pytest.mark.parametrize("cli", [True, False])
1734def 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

Callers

nothing calls this directly

Calls 6

run_copyFunction · 0.90
load_answersfile_dataFunction · 0.90
run_updateFunction · 0.90
build_file_treeFunction · 0.85
git_initFunction · 0.85
git_saveFunction · 0.85

Tested by

no test coverage detected