Example #1
0
def test_link(cruft_runner, cookiecutter_dir):
    get_cruft_file(cookiecutter_dir).unlink()
    result = cruft_runner([
        "link",
        "https://github.com/samj1912/cookiecutter-test",
        "--project-dir",
        str(cookiecutter_dir),
        "-y",
        "--directory",
        "dir",
    ])
    assert result.stdout == ""
    assert result.exit_code == 0
Example #2
0
def test_directory_and_checkout(tmpdir):
    output_path = cruft.create(
        "https://github.com/samj1912/cookiecutter-test",
        output_dir=Path(tmpdir),
        directory="dir",
        checkout="initial",
    )
    cruft_file = get_cruft_file(output_path)
    assert cruft_file.exists()
    assert cruft.check(output_path, checkout="initial")
    assert not cruft.check(output_path, checkout="updated")
    assert cruft.update(output_path, checkout="updated")
    assert cruft.check(output_path, checkout="updated")
    cruft_file.unlink()
    assert not cruft_file.exists()
    assert cruft.link(
        "https://github.com/samj1912/cookiecutter-test",
        project_dir=output_path,
        directory="dir",
        checkout="updated",
    )
    assert cruft.check(output_path, checkout="updated")
    # Add checks for strictness where master is an older
    # version than updated
    assert not cruft.check(output_path, strict=True)
    assert cruft.check(output_path, strict=False)
Example #3
0
def test_link_interactive(cruft_runner, cookiecutter_dir):
    cruft_file = get_cruft_file(cookiecutter_dir)
    commit = json.loads(cruft_file.read_text())["commit"]
    cruft_file.unlink()
    result = cruft_runner(
        [
            "link",
            "https://github.com/samj1912/cookiecutter-test",
            "--project-dir",
            str(cookiecutter_dir),
            "--directory",
            "dir",
        ],
        input=f"{commit}\n",
    )
    assert "Link to template at commit" in result.stdout
    assert result.exit_code == 0