MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / test_gc

Function test_gc

tests/commands/gc_test.py:39–59  ·  view source on GitHub ↗
(tempdir_factory, store, in_git_dir, cap_out)

Source from the content-addressed store, hash-verified

37
38
39def test_gc(tempdir_factory, store, in_git_dir, cap_out):
40 path = make_repo(tempdir_factory, 'script_hooks_repo')
41 old_rev = git.head_rev(path)
42 git_commit(cwd=path)
43
44 write_config('.', make_config_from_repo(path, rev=old_rev))
45 store.mark_config_used(C.CONFIG_FILE)
46
47 # update will clone both the old and new repo, making the old one gc-able
48 assert not install_hooks(C.CONFIG_FILE, store)
49 assert not autoupdate(C.CONFIG_FILE, freeze=False, tags_only=False)
50 assert not install_hooks(C.CONFIG_FILE, store)
51
52 assert _config_count(store) == 1
53 assert _repo_count(store) == 2
54 assert not gc(store)
55 assert _config_count(store) == 1
56 assert _repo_count(store) == 1
57 assert cap_out.get().splitlines()[-1] == '1 repo(s) removed.'
58
59 _remove_config_assert_cleared(store, cap_out)
60
61
62def test_gc_repo_not_cloned(tempdir_factory, store, in_git_dir, cap_out):

Callers

nothing calls this directly

Calls 12

make_repoFunction · 0.90
git_commitFunction · 0.90
write_configFunction · 0.90
make_config_from_repoFunction · 0.90
install_hooksFunction · 0.90
autoupdateFunction · 0.90
gcFunction · 0.90
_config_countFunction · 0.85
_repo_countFunction · 0.85
mark_config_usedMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected