Beispiel #1
0
def test_medium_save_config_with_more_ignores(workspace_config):
    workspace_config.ignores.pull.extend(["src/generated"])
    workspace_config.ignores.push.extend([".git", "*.pyc", "__pycache__"])
    workspace_config.ignores.both.extend(["build", IGNORE_FILE_NAME])
    medium = ClassicConfigurationMedium()
    medium.save_config(workspace_config)

    root = workspace_config.root
    assert (root / CONFIG_FILE_NAME).exists()
    assert (
        root /
        CONFIG_FILE_NAME).read_text() == "test-host.example.com:remote/dir\n"
    assert not (root / INDEX_FILE_NAME).exists()
    assert (root / IGNORE_FILE_NAME).exists()
    assert (root / IGNORE_FILE_NAME).exists()
    assert ((root / IGNORE_FILE_NAME).read_text() == f"""\
pull:
src/generated
push:
*.pyc
.git
__pycache__
both:
{CONFIG_FILE_NAME}
{IGNORE_FILE_NAME}
{INDEX_FILE_NAME}
build
""")
Beispiel #2
0
def test_medium_save_config_with_host_and_index(workspace_config):
    workspace_config.configurations.append(
        RemoteConfig(
            host="other-host.example.com", directory=Path("other/dir"), shell="bash", shell_options="some options"
        )
    )
    workspace_config.default_configuration = 1

    medium = ClassicConfigurationMedium()
    medium.save_config(workspace_config)

    root = workspace_config.root
    assert (root / CONFIG_FILE_NAME).exists()
    assert (
        (root / CONFIG_FILE_NAME).read_text()
        == """\
test-host.example.com:remote/dir
other-host.example.com:other/dir RSHELL=bash RSHELL_OPTS='some options'
"""
    )
    assert (root / INDEX_FILE_NAME).exists()
    assert (root / INDEX_FILE_NAME).read_text() == "2\n"
    assert (root / IGNORE_FILE_NAME).exists()
    assert (
        root / IGNORE_FILE_NAME
    ).read_text() == f"pull:\npush:\nboth:\n{CONFIG_FILE_NAME}\n{IGNORE_FILE_NAME}\n{INDEX_FILE_NAME}\n"
Beispiel #3
0
def test_medium_save_config_default(workspace_config):
    medium = ClassicConfigurationMedium()
    medium.save_config(workspace_config)

    root = workspace_config.root
    # it's default config so it should only create a .remote file and .remoteignore
    assert (root / CONFIG_FILE_NAME).exists()
    assert (root / CONFIG_FILE_NAME).read_text() == "test-host.example.com:remote/dir\n"
    assert not (root / INDEX_FILE_NAME).exists()
    assert (root / IGNORE_FILE_NAME).exists()
    assert (
        root / IGNORE_FILE_NAME
    ).read_text() == f"pull:\npush:\nboth:\n{CONFIG_FILE_NAME}\n{IGNORE_FILE_NAME}\n{INDEX_FILE_NAME}\n"