Example #1
0
def test_autoupdate_local_hooks(in_git_dir, store):
    config = sample_local_config()
    add_config_to_repo('.', config)
    assert autoupdate(C.CONFIG_FILE, store, freeze=False, tags_only=False) == 0
    new_config_writen = read_config('.')
    assert len(new_config_writen['repos']) == 1
    assert new_config_writen['repos'][0] == config
Example #2
0
def test_autoupdate_local_hooks(in_git_dir, store):
    config = sample_local_config()
    add_config_to_repo('.', config)
    assert autoupdate(C.CONFIG_FILE, store, tags_only=False) == 0
    new_config_writen = read_config('.')
    assert len(new_config_writen['repos']) == 1
    assert new_config_writen['repos'][0] == config
Example #3
0
def test_autoupdate_local_hooks_with_out_of_date_repo(
        out_of_date_repo, in_tmpdir, store,
):
    stale_config = make_config_from_repo(
        out_of_date_repo.path, rev=out_of_date_repo.original_rev, check=False,
    )
    local_config = sample_local_config()
    config = {'repos': [local_config, stale_config]}
    write_config('.', config)
    assert autoupdate(C.CONFIG_FILE, store, tags_only=False) == 0
    new_config_writen = read_config('.')
    assert len(new_config_writen['repos']) == 2
    assert new_config_writen['repos'][0] == local_config
Example #4
0
def test_autoupdate_local_hooks_with_out_of_date_repo(
        out_of_date_repo, in_tmpdir, store,
):
    stale_config = make_config_from_repo(
        out_of_date_repo.path, rev=out_of_date_repo.original_rev, check=False,
    )
    local_config = sample_local_config()
    config = {'repos': [local_config, stale_config]}
    write_config('.', config)
    assert autoupdate(C.CONFIG_FILE, store, tags_only=False) == 0
    new_config_writen = read_config('.')
    assert len(new_config_writen['repos']) == 2
    assert new_config_writen['repos'][0] == local_config
Example #5
0
def test_always_run_alt_config(
    cap_out,
    repo_with_passing_hook,
    mock_out_store_directory,
):
    repo_root = '.'
    config = read_config(repo_root)
    config[0]['hooks'][0]['always_run'] = True
    alt_config_file = 'alternate_config.yaml'
    add_config_to_repo(repo_root, config, config_file=alt_config_file)

    _test_run(cap_out,
              repo_with_passing_hook, {}, (b'Bash hook', b'Passed'),
              0,
              stage=False,
              config_file=alt_config_file)
Example #6
0
def test_always_run_alt_config(cap_out, store, repo_with_passing_hook):
    repo_root = '.'
    config = read_config(repo_root)
    config['repos'][0]['hooks'][0]['always_run'] = True
    alt_config_file = 'alternate_config.yaml'
    add_config_to_repo(repo_root, config, config_file=alt_config_file)

    _test_run(
        cap_out,
        store,
        repo_with_passing_hook,
        {},
        (b'Bash hook', b'Passed'),
        0,
        stage=False,
        config_file=alt_config_file,
    )